﻿var MailConference = Class.create();
MailConference.prototype = {
    initialize: function(){
		this.init();
    },
    // 初始化类中的部分全局变量
    init: function(){
        this.folder = 1;
        this.page = 1;
		this.list = [];
		this.cacheList = [];
		this.conferenceItem = {};
		this.currentConference = [];
		this.F = FOLDER.evalJSON();
		this.optionCss = {'width':'40px', 'marginTop':'2px', 'float':'right'};
		// 当前会话的thread
		this.currentCid = 0;
		// 未读列表中，已经读过（或者说被删除）的回话
		this.delConference = {};
		// 如果会话列表中是一封草稿，记录草稿的编辑器对象
		this._editor = {};
		// 记录草稿的上传附件对象
		this._upload = {};
		// 记录写信时输入框的自动匹配对象
		this._autocomplete = {};
		this._page();
		this._folder();
		// 读会话页面记录被创建的菜单节点（离开读信页面好将这些节点上的事件清除）
		this._menu_event_list = [];
		// 历史记录
		this.rsh = false;
		// 信件区域内容的宽度是否能够大于屏幕的显示宽度（是否出现横向滚动条）
		this._mail_content_is_max = false;
		// location文件夹名
		try {
			this.f = getLocation().folder ? getLocation().folder : 'main';
		} catch(e) {
			this.f = 'main';
		}
		// 列表页面记录用户的操作位置
		this.scrollPos = 0;
		// 多彩星标
		this.multiStar = {
			timer: null,
        	color: ['#4c4c4c', '#ff6600', '#28593E', '#005BA2', '#BD1000', '#7733AA'],
        	// img: ['/icon_star_grey.gif', '/icon_star.gif', '/icon_starg.gif', '/icon_over.gif', '/icon_starr.gif', '/icon_starz.gif'],
			star: ['icon_star0', 'icon_star1', 'icon_star2', 'icon_star3', 'icon_star4', 'icon_star5'],
        	id: 0,
        	title : ['普通', '重要', '关注', '完成', '后续工作', '有疑问']
		};
		// 缓存展开全部的会话
		this.conferenceAllMails = {};
		// 载入页面，如果默认为会话模式，记录会话页面第一页的缓存（会话目前没有实现所有列表和都会话的缓存机制），会话模式和普通模式的同时存在确实为开发增加了不小的成本。。。。。。。。
		// this.firstLoadListCache = [];
		
		// 会话中的缓存数据
		// 会话列表的缓存数据
		this.conferenceListCache = {};
		// 会话内容的缓存数据
		this.conferenceThreadCache = {};
		// 移动、删除邮件的操作提示
		this.op_tips = {
			'fid_0': '邮件操作成功！',        // 移动邮件夹
			'fid_-1': '邮件已经被永久删除！', // 永久删除邮件
			'fid_4': '邮件已经被删除！',      // 删除邮件
			'fid_1': '邮件已经不是垃圾邮件！',// 非垃圾邮件操作
			'fid_3': '邮件已经被垃圾举报！'   // 垃圾邮件举报操作
		};
    },
	_page: function() {
		this.currentTotal = this.getFolderItem(this.folder).thread_total;
		this.totalPage = (this.currentTotal%PAGE_CAPACITY) > 0 ? parseInt(this.currentTotal/PAGE_CAPACITY) + 1 : parseInt(this.currentTotal/PAGE_CAPACITY);
	},
	_folder: function() {
		this._F = {};
		this.F.folders.each(function(item) {
			this._F[item.folder_id] = item.name;
		}.bind(this));
		this._F[-2] = '未读邮件';
	},
	initEvent: function() {
		var self = this;
		var _tmp_dl = [
			{name: 'firstpage', exec: function(event) {
                                                                      if(self.folder > -5){
				self.getMailList(self.folder, 1);
                                                                      }else{
                                        mailConference.clearListCache(mailConference.folder);
                                        self.getMailList(self.folder, 1, mailStarList.reset_selected, null, {
					sort: 'star',
					order: mailStarList.clickObj
				});
                                                                      }
			}},
			{name: 'prevpage', exec: function(event) {
                                                                      if(self.folder > -5){
				self.getMailList(self.folder, (self.page-1));
                                                                      }else{
                                        mailConference.clearListCache(mailConference.folder);
				self.getMailList(self.folder, (self.page-1), mailStarList.reset_selected, null, {
					sort: 'star',
					order: mailStarList.clickObj
				});
                                                                      }
			}},
			{name: 'nextpage', exec: function(event) {
                                                                      if(self.folder > -5){
				self.getMailList(self.folder, (self.page+1));
                                                                      }else{
                                    mailConference.clearListCache(mailConference.folder);
				self.getMailList(self.folder, (self.page+1), mailStarList.reset_selected, null, {
					sort: 'star',
					order: mailStarList.clickObj
				});
                                                                      }
			}},
			{name: 'endpage', exec: function(event) {
                                                                      if(self.folder > -5){
				self.getMailList(self.folder, self.totalPage);
                                                                      }else{
                                        mailConference.clearListCache(mailConference.folder);
				self.getMailList(self.folder, self.totalPage, mailStarList.reset_selected, null, {
					sort: 'star',
					order: mailStarList.clickObj
				});
                                                                      }
			}},
			{name: 'selpage', exec: function(event, EL) {
				var mune_page = [];
				var _a = []
				for(var i=0;i<self.totalPage;i++) {
					_a.push(i+1);
				}
				_a.each(function(item) {
					mune_page.push({
						text: item,
						onclick: function() {
                                                                      if(self.folder > -5){
							self.getMailList(self.folder, item);
                                                                      }else{
                                        mailConference.clearListCache(mailConference.folder);
                                        self.getMailList(self.folder, item, mailStarList.reset_selected, null, {
					sort: 'star',
					order: mailStarList.clickObj
				});
                                                                      }
						}
					})
				});
				menu.showMenu(EL.parentNode, DOM.sohuMailMain, mune_page, 'menu menu_sel', true, null, event);
			}},
			{name: 's_delete', exec: function(event) {
				self.delMailInList('delete');
			}},
			{name: 's_delt', exec: function(event) {
				self.delMailInList('del');
			}},
			{name: 's_undelt', exec: function(event) {
				self.delMailInList('undel');
			}},
			{name: 's_move', exec: function(event, EL) {
				try {
					var l = self.getMenuFolderList();
					if(l.length == 0) {
						Tips.show('没有可移至的文件夹', 3);
						return false;
					}
					menu.showMenu(EL, DOM.sohuMailMain, l, 'menu', true, null, event);
				} catch(e) {}
			}},
			{name: 's_spam', exec: function(event) {
				self.delMailInList('spam');
				jsoplog.ucCapture('spammail');
			}},
			{name: 's_unspam', exec: function(event) {
				self.delMailInList('unspam');
			}},
			{name: 's_star', exec: function(event, EL) {
				var p = EL.parentNode.parentNode;
				var _id = p.id ? p.id : p.getAttribute('id');
				var _star = EL.star ? EL.star : EL.getAttribute('star');
				_star = (parseInt(_star)+1)%6;
				if(_id) _id = _id.split('_')[1];
				var _mid = 0;
                                var _t_list = null;
				self.cacheList.each(function(item) {
					if(item.thread == _id) {
						_mid = item.rowids[item.rowids.length-1];
                                                _t_list = item;
					}
				});
                                if(self.folder < -4)
                                    self._setStar(EL, _mid, _star, _id);
                                else
                                    self._setStar(EL, _mid, _star, _id, _t_list);
			}}
		];
		/******************** 会话列表的事件注册 *******************/
		
		var _tmp_dl_clk = [
			{name: 'conference_item', exec: function(event, EL) {
				self.setConfSel(EL);
			}},
			{name: 'conference_all', exec: function(event, EL) {
				self.setConfAllSel(EL);
			}}
		];
		
		
		var _gpcn = Element.getParentNodeByClassName, _gpatr = Element.getParentNodeByAttribute, _gptn = Element.getParentNodeByTagName;
		DOM.mailList.observe('click', function(event) {
			if(!isConferenceMode) return false;
			var el = event.target;
			_tmp_dl.each(function(item) {
				var e = _gpcn(el, item.name);
				if(e) {
					Event.stop(event);
					item.exec(event, e);
				}
				return false;
			});
			_tmp_dl_clk.each(function(item) {
				var e = _gpcn(el, item.name);
				if (e) {
					item.exec(event, e);
				}
				return false;
			});
		}).observe('mouseover', function(event) {
			if(!isConferenceMode) return false;
			
			var el = event.target, e = _gpcn(el, 'bt-common');
			e && $(e).addClassName('bt-common-hover');
			
			(function() {
				var _e = _gptn(el, 'tr'), _eid = _e.getAttribute('id');
				if(_e && _eid && _eid.startsWith('tr')) TableMouseOver(_e);
				if ($(el).hasClassName('selpage')) $(el).addClassName('select-arrow-over');
			})();
		}).observe('mouseout', function(event) {
			if(!isConferenceMode) return false;
			
			var el = event.target, e = _gpcn(el, 'bt-common');
			e && $(e).removeClassName('bt-common-hover');
			
			(function() {
				var _e = _gptn(el, 'tr'), _eid = _e.getAttribute('id');
				if(_e && _eid && _eid.startsWith('tr')) TableMouseOut(_e);
				if($(el).hasClassName('selpage')) $(el).removeClassName('select-arrow-over');
			})();
		}).observe('mousedown', function(event) {
			if(!isConferenceMode) return false;
			
			var el = event.target, e = _gpcn(el, 'bt-common');
			e && $(e).addClassName('bt-common-press');
			
			if(!Event.isLeftClick(event)) return false;
			var cid = _gpatr(el, 'cid');
			if(cid) this.getMailRead(cid.attribute);
			(function() {
				if($(el).hasClassName('selpage')) $(el).addClassName('select-arrow-press');
			})();
		}.bind(this)).observe('mouseup', function(event) {
			if(!isConferenceMode) return false;
			
			var el = event.target, e = _gpcn(el, 'bt-common');
			e && $(e).removeClassName('bt-common-press');
			
			(function() {
				if($(el).hasClassName('selpage')) $(el).removeClassName('select-arrow-press');
			})();
		});
		
		/******************** 读会话的事件注册 *******************/
		var _tmp_read_dl = [
			{name: 's_rt', exec: function(event) {
				self.rtListPage();
			}},
			{name: 's_prev', exec: function(event) {
				self.getMailRead(PREV_ID);
			}},
			{name: 's_next', exec: function(event) {
				self.getMailRead(NEXT_ID);
			}},
			{name: 'last_reply_textarea', exec: function(event) {
				self.replyMail(self._last_id, 'replyall');
			}}
		];
		var getids = function() {
			var ids = [];
			self.currentConference.each(function(item) {
				ids.push(item.rowid);
			});
			return ids;
		};
		
		var _tmp_read_dl_clk = [
			{name: 's_delete', exec: function(event) {
				self.delMail(getids(), 'delete');
			}},
			{name: 's_delt', exec: function(event) {
				self.delMail(getids(), 'del');
			}},
			{name: 's_spam', exec: function(event) {
				self.delMail(getids(), 'spam');
				jsoplog.ucCapture('spammail');
			}},
			{name: 's_unspam', exec: function(event) {
				self.delMail(getids(), 'unspam');
			}},
			{name: 's_move', exec: function(event, EL) {
				// var v = Element.getParentNodeByClassName(EL, 's_move');
				if(EL) {
					function func(id) {
						self.delMail(getids(), id);
					}
					var l = self.getMenuFolderList(func);
					if(l.length == 0) {
						Tips.show('没有可移至的文件夹', 3);
						return false;
					}
					menu.showMenu(EL, DOM.sohuMailMain, l, 'menu', true, null, event);
				}
			}},
			{name: 'send_draft', exec: function(event, EL) {
				var rid = Element.getParentNodeByAttribute(EL, 'rid');
				self.sendMail(parseInt(rid.attribute));
			}},
			{name: 'save_draft', exec: function(event, EL) {
				var rid = Element.getParentNodeByAttribute(EL, 'rid');
				self.saveMail(parseInt(rid.attribute));
			}},
			{name: 'delt_draft', exec: function(event, EL) {
				var rid = Element.getParentNodeByAttribute(EL, 'rid');
				self.deltDraftMail(parseInt(rid.attribute));
			}},
			{name: 'draft_cc', exec: function(event, EL) {
				self.showDraftCC(event, EL);
			}},
			{name: 'draft_bcc', exec: function(event, EL) {
				self.showDraftBCC(event, EL);
			}},
			{name: 'draft_sub', exec: function(event, EL) {
				self.showDraftSub(event, EL);
			}},
			{name: 's_isclosefile', exec: function(event, EL) {
				self.showAttachFile(event, EL);
			}},
			{name: 's_save_addr', exec: function(event, EL) {
				self.saveAddr(EL, event);
			}},
			{name: 's_addr_refuse', exec: function(event, EL) {
				self.refuseAddr(EL);
			}},
			{name: 's_save_all_addr', exec: function(event, EL) {
				self.saveAllAddr(EL, event);
			}},
			{name: 's_reply', exec: function(event, EL) {
				self.replyFunction(event, EL);
			}},
			{name: 's_reply_all', exec: function(event, EL) {
				self.replyAllFunction(event, EL);
			}},
			{name: 's_forward', exec: function(event, EL) {
				self.forwardFunction(event, EL);
			}},
			{name: 's_expand_all', exec: function(event, EL) {
				self.expandAllFunction(event, EL);
			}},
			{name: 's_shrink_all', exec: function(event, EL) {
				self.shrinkAllFunction(event, EL);
			}},
			{name: 's_filepreview', exec: function(event, EL) {
				self.attachFilePreview(event, EL);
			}},
            {name: 'reply_notifier', exec: function(event, EL) {
            	var mid = EL.getAttribute('mid');
                if(mid){
                	self.reply_notifier(EL, 1, mid);
                }
			}}, 
			{name: 'cancel_reply_notifier', exec: function(event, EL) {
            	var mid = EL.getAttribute('mid');
                if(mid){
                    self.reply_notifier(EL, 0, mid);
                }
            }},
			{name: 'edm_activity', exec: function(event, EL) {
				var exec_event = EL.getAttribute('eventname');
				if(!exec_event || exec_event == '') return false;
				try {
					return new Function('return ' + exec_event)();
				} catch(e) {}
			}},
			{name: 's_show_item', exec: function(event, EL) {
				var mid = EL.getAttribute('mid');
				self.isShow(mid);
			}, cevt: ['s_show_info','s_star']},
			{name: 's_bar_show_info', exec: function(event, EL) {
				var mid = EL.getAttribute('mid');
				self.isHeadInfoShow(mid, event);
			}},
			{name: 's_bar_showinfo', exec: function(event, EL) {
				var mid = EL.getAttribute('mid');
				self.isHeadInfoShow(mid, EL);
			}},
			{name: 's_show_info', exec: function(event, EL) {
				var mid = EL.getAttribute('mid');
				self.isHeadInfoShow(mid, EL);
			}},
			{name: 's_bar_reply', exec: function(event, EL) {
				var mid = EL.getAttribute('mid');
				try {
					if (!self._editor_content_check('e_' + mid, function(){
						self.replyMail(mid, 'reply');
					})) 
						return false;
				} catch(e) {
				}
				self.replyMail(mid, 'reply');
			}},
			{name: 's_bar_replyall', exec: function(event, EL) {
				var mid = EL.getAttribute('mid');
				if(!self._editor_content_check('e_' + mid, function() {
					self.replyMail(mid, 'replyall');
				})) return false;
				self.replyMail(mid, 'replyall');
			}},
			{name: 's_bar_forward', exec: function(event, EL) {
				var mid = EL.getAttribute('mid');
				if(!self._editor_content_check('e_' + mid, function() {
					self.replyMail(mid, 'forward');
				})) return false;
				self.replyMail(mid, 'forward');
			}},
			{name: 's_bar_del', exec: function(event, EL) {
				var mid = EL.getAttribute('mid');
				if(!self._editor_content_check('e_' + mid, function() {
					self.delMail([mid], 'del');
				})) return false;
				self.delMail([mid], 'del');
			}},
			{name: 's_bar_delete', exec: function(event, EL) {
				var mid = EL.getAttribute('mid');
				if(!self._editor_content_check('e_' + mid, function() {
					self.delMail([mid], 'delete');
				})) return false;
				self.delMail([mid], 'delete');
			}},
			{name: 's_bar_source', exec: function(event, EL) {
				var mid = EL.getAttribute('mid');
				self.sourceMail(mid);
			}},
			{name: 's_bar_download', exec: function(event, EL) {
				var mid = EL.getAttribute('mid');
				self.downloadMail(mid);
			}},
			{name: 's_bar_print', exec: function(event, EL) {
				var mid = EL.getAttribute('mid');
				self.printMail(mid);
			}},
			{name: 's_bar_menu', exec: function(event, EL) {
				var mid = EL.getAttribute('mid'), _item = null;
				self.currentConference.each(function(item) {
					if(item.rowid == mid) _item = item;
				});
				list = self.getMenuList(_item);
				menu.showMenu(EL, DOM.sohuMailMain, list, 'dialog_menu', true, null, event);
			}},
			{name: 's_star', exec: function(event, EL) {
				var sid = EL.getAttribute('sid');
				self._setStar(EL, sid);
			}},
			{name: 's_show_blockquote', exec: function(event, EL) {
				var e = EL.nextSibling, en = null;
				while(e) {
					if(e.nodeType == 1 && Element.hasClassName(e, 'sohu_quote')) {
						en = e;
						break;
					}
					e = e.nextSibling;
				}
				if($(en).visible()) {
					EL.innerHTML = '显示引用文字';
					$(en).hide();
				} else {
					EL.innerHTML = '隐藏引用文字';
					$(en).show();
				}
			}}
		];
		
		
		var _gpcn = Element.getParentNodeByClassName, _gpatr = Element.getParentNodeByAttribute;
		DOM.readMail.observe('click', function(event) {
			if(!isConferenceMode) return false;
			try {
				if (mailSearch && mailSearch.searchReadPanel) return false;
			} catch(e) {}
			var el = event.target;
			_tmp_read_dl.each(function(item) {
				var e = _gpcn(el, item.name);
				if (e) Event.stop(event);
				return false;
			});
			_tmp_read_dl_clk.each(function(item) {
				if(item.cevt) {
					var _flag = false;
					item.cevt.each(function(_item) {
						if(_gpcn(el, _item)) _flag = true;
					});
					if(_flag) return false;
				}
				var e = _gpcn(el, item.name);
				if (e) {
					item.exec(event, e);
					Event.stop(event);
				}
				return false;
			});
		}).observe('mouseover', function(event) {
			if(!isConferenceMode) return false;
			
			var el = event.target, e = _gpcn(el, 'bt-common');
			e && $(e).addClassName('bt-common-hover');
			
			(function() {
				var e = _gpcn(el, 's_operate_all');
				self._showOprAll(e);
			})();
			
			(function() {
				var e = _gpcn(el, 's_attach_item_area');
				if(e) {
					$(e).addClassName('attach-item-over');
					eventStop(event);
					return false;
				}
			})();
		}).observe('mouseout', function(event) {
			if(!isConferenceMode) return false;
			
			var el = event.target, e = _gpcn(el, 'bt-common');
			e && $(e).removeClassName('bt-common-hover');
			
			(function() {
				var e = _gpcn(el, 's_operate_all');
				self._hideOprAll(e);
			})();
			
			(function() {
				return;
				var e = _gpcn(el, 's_operate_all_v');
				self._hideOprAll_v(e);
			})();
			
			(function() {
				var e = _gpcn(el, 's_attach_item_area');
				if(e) {
					$(e).removeClassName('attach-item-over');
					eventStop(event);
					return false;
				}
			})();
		}).observe('mousedown', function(event) {
			if(!isConferenceMode) return false;
			
			var el = event.target, e = _gpcn(el, 'bt-common');
			e && $(e).addClassName('bt-common-press');
			
			if(!Event.isLeftClick(event)) return false;
			(function() {
				try {
					if (mailSearch && mailSearch.searchReadPanel) return false;
				} catch(e) {}
				_tmp_read_dl.each(function(item) {
					if(item.cevt) {
						var _flag = false;
						item.cevt.each(function(_item) {
							if(_gpcn(el, _item)) _flag = true;
						});
						if(_flag) return false;
					}
					var e = _gpcn(el, item.name);
					if(e) {
						eventStop(event);
						item.exec(event, e);
						return false;
					}
				});
			})();
		}.bind(this)).observe('mouseup', function(event) {
			if(!isConferenceMode) return false;
			var el = event.target, e = _gpcn(el, 'bt-common');
			e && $(e).removeClassName('bt-common-press');
		});
	},
	_showOprAll: function(EL) {
		var e = EL;
		if(!e) return;
		var ep = e.previousSibling, ec = e.firstChild;
		// var ep = e.firstChild, ec = e.lastChild.firstChild;
		
		if(!ep || !ec) return;
		var es = ep.getAttribute('isshow');
		if(es == 'false') {
			Effect.BlindLeft(ep, {afterSetup: function(effect) {
      				effect.element.makeClipping().setStyle({width: '0px'}).show().setAttribute('isshow', '');
    			},
    			afterFinishInternal: function(effect) {
      				effect.element.undoClipping().setAttribute('isshow', 'true');
					$(ec).removeClassName('arrow-right').addClassName('arrow-left');
    			},
				duration: 0.3}
			);
		}
	},
	_hideOprAll: function(EL) {
		var e = EL;
		if(!e) return;
		var ep = e.previousSibling, ec = e.firstChild;
		// var ep = e.firstChild, ec = e.lastChild.firstChild;
		
		if(!ep || !ec) return;
		var es = ep.getAttribute('isshow');
		if(es == 'true') {
			Effect.BlindRight(ep, {afterSetup: function(effect) {
					effect.element.makeClipping().setAttribute('isshow', '');
				},
				afterFinishInternal: function(effect) {
      				effect.element.hide().undoClipping().setAttribute('isshow', 'false');
					$(ec).removeClassName('arrow-left').addClassName('arrow-right');
    			},
				duration: 0.3}
			);
		}
	},
	_hideOprAll_v: function(EL) {
		var e = EL;
		if(!e) return;
		var ep = e, ec = e.nextSibling.firstChild;
		// var ep = e.firstChild, ec = e.lastChild.firstChild;
		
		if(!ep || !ec) return;
		var es = ep.getAttribute('isshow');
		if(es == 'true') {
			Effect.BlindRight(ep, {afterSetup: function(effect) {
					effect.element.makeClipping().setAttribute('isshow', '');
				},
				afterFinishInternal: function(effect) {
      				effect.element.hide().undoClipping().setAttribute('isshow', 'false');
					$(ec).removeClassName('arrow-left').addClassName('arrow-right');
    			},
				duration: 0.3}
			);
		}
	},
	_setStar: function(_el, _id, _star, _thread) {
		if(arguments.length < 3) {
			_star = Element.getParentNodeByAttribute(_el, 'star').attribute;
			_star = (parseInt(_star) + 1)%6;
			try {
				this.setThreadStarCache(this.currentConference[0].thread, _id, _star, this.folder);
			} catch(e) {}
		} else {
			try {
				this.setListStarCache(arguments[3], _star, this.folder);
			} catch(e) {}
		}
		if(this.multiStar.timer) {
			this.stopStar();
			try {
				if (_id != this.multiStar.id) {
					this.setStarClass(this.multiStar.imgel, this.multiStar.star[0]);
					this.multiStar.imgel.title = this.multiStar.title[0];
					this.multiStar.subel.style.color = this.multiStar.color[0];
				}
			} catch(e) {}
		}
		
		try {
			if (_el.parentNode.nodeName.toLowerCase() == 'td') {
				var _sub = _el.parentNode.nextSibling.firstChild;
				_sub.style.color = this.multiStar.color[_star];
			}
		} catch(e) {}
		this.setStarClass(_el, this.multiStar.star[_star]);
		_el.title = this.multiStar.title[_star];
		_el.setAttribute('star', _star);
		if(_id != 0) {
			var _p = {
				id: _id,
				method: 2,
				star: _star, 
                                thread: _thread,
                                folder: this.folder
			};
			mail_change_star(_p);
		}
		try {
			PROFILE.usestar = 1;
		} catch(e) {}
	},
	// 计算读信时，返回到当前信件所在的列表页面
	rtListPage: function() {
		try {
			if (this.folder <= -5) {
				this.clearListCache(this.folder);
			}
			var _id = this.currentConference[0].thread, _index = 0, _flag = false;
			this.cacheList.each(function(item, index){
				if (item.thread == _id && !_flag) {
					_index = index - 1;
					_flag = true;
				}
			});
			// var _page = this.page + parseInt(_index / PAGE_CAPACITY);
			var _pp = typeof this._prev_page != 'number' ? -1 : this._prev_page;
			var _page = _pp + 2 + parseInt(_index/PAGE_CAPACITY);
			if (this.folder > -5) {
				this.getMailList(this.folder, _page);
			} else {
				this.clearListCache(this.folder);
				this.getMailList(this.folder, _page, mailStarList.reset_selected, null, {
					sort: 'star',
					order: mailStarList.clickObj
				});
			}
		} catch(e) {}
	},
	getMenuFolderList: function(func) {
		var l = [];
		if(this.folder == 2) return l;
		this.F.folders.each(function(item) {
			if(item.folder_id != mailConference.folder && item.folder_id != -2 && item.folder_id != 2 && item.folder_id != 3 && item.folder_id != 4 && item.folder_id != 5 && item.folder_id > -5) {
				var self = this;
				l.push({
					text: item.name,
					onclick: function() {
						if (func) {
							func(item.folder_id);
						} else {
							self.delMailInList(item.folder_id);
						}
						return false;
					}
				});
			}
		}.bind(this));
		return l;
	},
    getMailList: function() {
        var folder = arguments[0] ? arguments[0] : this.folder;
        var page = arguments[1] ? arguments[1] : this.page;
		this.confCallbackFunc = arguments[2] ? arguments[2] : null;
        var _sort = arguments[4];
        page = (page > 0) ? page : 1;
        var start = (page - 1) * PAGE_CAPACITY;
        var params = {
            folder: folder,
            start: start,
            length: PAGE_CAPACITY
        };
		if(arguments[3]) {
			var cf = arguments[3];
			conversation_list(params, function(ret) {
				cf(ret);
			});
			return false;
		}
		if(_sort && typeof _sort == 'object') {
		try {
			Object.extend(params, _sort);
		} catch(e) {}
		}
		
		var _cache_data = this.getListCache(folder, page);
		/*
		if (this.firstLoadListCache.length > 0 && folder == 1) {
			this.getMailListCallback(folder, page, this.firstLoadListCache);
		} 
		else 
		*/
		if(_cache_data && _cache_data.length > 0) {
			this.getMailListCallback(folder, page, _cache_data);
		} else {
			conversation_list(params, this.getMailListCallback.bind(this, folder, page));
		}
    },
    getMailListCallback: function() {
		if(typeof arguments[2] != 'object') {
			return;
		}
		
		this.folder = arguments[0];
		this.page = arguments[1];
		this._page();
		this._prev_page = (this.page <= 1) ? null : this.page-2, this._next_page = this.page;
                try{
                    ret = arguments[2];
                    if(ret.status == false){
                        mailfolder.check_callback = function(){ML();};
                        mailfolder.valid_success(ret);
                        return;
                    }
                }catch(e){}
		hiddenAllPanel();
		
		DOM.mailList.show();
		this.list = arguments[2];
		this.cacheList = arguments[2];
		
		if(!this.hasListCache(this.folder, this.page) && this.folder != -2) {
			this.setListCache(arguments[2], this.folder, this.page);
		}
		
		var _op = [];
		_op.push('<div class="l-area">');
		_op.push(this.createDeleteEL(true));
		if (this.folder != 2 && this.folder != 3 && this.folder != 4) _op.push(this.createDelEL());
		if (this.folder == 4) _op.push(this.createUnDelEL());
		if (this.folder == 5) _op.push(this.createUnspamEL());
		else if(this.folder != 2 && this.folder != 3) _op.push(this.createSpamEL());
		_op.push(this.createSprEL());
		if(this.folder != 2 && this.folder != 3) _op.push(this.createMoveEL());
		_op.push('</div>');
		_op.push('<div class="r-area">');
		if((this.totalPage < 2) || (this.page == 1 && this.page == this.totalPage)) {
			_op.push(this.createFirstPageEL(true));
			_op.push(this.createPrevPageEL(true));
			_op.push(this.createNextPageEL(true));
			_op.push(this.createEndPageEL(true));
		} else if(this.page == 1) {
			_op.push(this.createFirstPageEL(true));
			_op.push(this.createPrevPageEL(true));
			_op.push(this.createNextPageEL());
			_op.push(this.createEndPageEL());
		} else if(this.page == this.totalPage) {
			_op.push(this.createFirstPageEL());
			_op.push(this.createPrevPageEL());
			_op.push(this.createNextPageEL(true));
			_op.push(this.createEndPageEL(true));
		} else {
			_op.push(this.createFirstPageEL());
			_op.push(this.createPrevPageEL());
			_op.push(this.createNextPageEL());
			_op.push(this.createEndPageEL());
		}
		_op.push(this.createSelPageEL(this.page));
		_op.push('</div>');
		var _opht = _op.join('');
		
		var ad_ct = function() {
			try {
				if(_is_xj || USE_SYS.name != 'sohu' || !sohuMailAds) return {t:'',b:''};
			} catch(e) {
				return {t:'',b:''};
			}
			var _ad1 = sohuMailAds.top.ads1.content[0],
				_ad2 = sohuMailAds.top.ads2.content[0],
				_ad3 = sohuMailAds.top.ads3.content[0],
				_bad = sohuMailAds.bottom.ads.content[0];
			var _top_ad = '<tr style="background:#FFFBDE;">'
				+'<td colspan="8" style="width:100%;">'
				+'<div class="f-lf" style="text-align:center;width:33%;"><a href="' + _ad1.href + '" target="_blank" hidefocus="true">' + _ad1.text + '</a></div>'
				+'<div class="f-lf" style="text-align:center;width:33%;"><a href="' + _ad2.href + '" target="_blank" hidefocus="true">' + _ad2.text + '</a></div>'
				+'<div class="f-lf" style="text-align:center;width:33%;"><a href="' + _ad3.href + '" target="_blank" hidefocus="true">' + _ad3.text + '</a></div>'
				+'</td>'
				+'</tr>',
				_bottom_ad = '<tr style="background:#FFFBDE;">'
				+'<td colspan="8" style="text-align:center;border-bottom:none;">'
				+'<a href="' + _bad.href + '" target="_blank" hidefocus="true">' + _bad.text + '</a>'
				+'</td>'
				+'</tr>';
			return {t:_top_ad, b:_bottom_ad};
		};
		
        var content = [];
		// content.push(conf_operate_bar1);
		content.push('<div class="operate">'+ _opht +'</div>');
        content.push('<div id="conference_content" class="m-content">');
        content.push('<table border="0" cellpadding="0" cellspacing="0" id="inbox" class="inbox">');
        content.push(conf_list_title);
		content.push(this.createSubHead(ret));
		
		content.push(ad_ct().t);
		
		// content.push('<tr id="mail_list_top" style="background:#FFFBDE;display:none;">');
		// content.push('<td colspan="8" style="width:100%;"><div id="top_ad_1" style="float:left;text-align:center;width:33%;"></div><div id="top_ad_2" style="float:left;text-align:center;width:33%;"></div><div id="top_ad_3" style="width:33%;text-align:center;float:left;"></div></td>');
		// content.push('</tr>');
		if(arguments[2].length == 0) {
			content.push('<tr><td colspan="8"><div class="m-no-list"> 当前邮件夹没有邮件 </div></td><td/></tr>');
		} else {
        	arguments[2].each(function(item){
				try {
					content.push(this.createItemList(item));
				} catch(e) {}
        	}.bind(this));
		}
		content.push(ad_ct().b);
        // content.push('<tr id="mail_list_bottom" style="background:#FFFBDE;display:none;">');
		// content.push('<td colspan="8" id="bottom_ad" style="text-align:center;border-bottom:none;"></td>');
		// content.push('</tr>');
        content.push('</table>');
        content.push('</div>');
		// content.push(conf_operate_bar2);
		content.push('<div class="operate2">'+ _opht +'</div>');
		DOM.mailList.innerHTML = content.join('');
		
		try {
			// 清除掉刚登录进来时的缓存
			// if(this.firstLoadListCache.length > 0) this.firstLoadListCache = [];
		} catch(e) {}
		try {
			this.setConferenceNew(this.F.folders);
		} catch(e) {}
		try {
			var _self = this;
			(function(){
				var _f = 0;
				if (_self.currentCid != 0) {
					_f = _self.currentCid;
				} else {
					var _fst_u = 0, _fst = 0, _f = 0;
					_self.cacheList.each(function(item, index){
						if (index == 0) 
							_fst = item.thread;
						if (item.unread > 0 && _fst_u == 0) 
							_fst_u = item.thread;
					});
					_f = _fst_u != 0 ? _fst_u : _fst;
				}
				try {
					_self.setUserArrow(_f);
				} catch (e) {}
			})();
		} catch(e) {}
		
		try {
            mailPop.setPopMailListTag(this.cacheList);
        } catch (e) {}
		// 如果有callback传入，继续执行callback函数（为了ajax请求的顺序执行）
		try {
			if(this.confCallbackFunc && typeof this.confCallbackFunc == 'function') this.confCallbackFunc();
		} catch(e) {}
		// 展示多彩星标
		try {
			this.runStar(this.cacheList);
		} catch(e) {}
		// 提示信息
		try {
			this.createMessageInfo(messageInfo);
		} catch(e) {}
		try {
			if(this.scrollPos > 0) DOM.sohuMailMain.scrollTop = this.scrollPos;
		} catch(e) {}
		try {
			this.listenPos();
		} catch(e) {}
		try {
			changeToolbarStyle('mailList', this.folder);
		} catch(e) {}
		try {
			deleteLoadPage();
		} catch(e){}
		
		
		
		if (this.page == 1) {
			addAjaxHistory('mailList_' + this.folder, 'changePanel("mailList",' + this.folder + ', true)', this._F[this.folder], mailList._is_rsh);
		} else {
			addAjaxHistory('mailList_' + this.folder + '_' + this.page, 'mailList._is_rsh=true;mailConference.getMailList('+ this.folder +', '+ this.page +')', this._F[this.folder], mailList._is_rsh);
		}
		mailList._is_rsh = false;
    },
	
	// 如果列表页面没有星标，多彩星标自动闪烁
	runStar: function(ret) {
		try {
			if(PROFILE.usestar) return false;
		} catch(e) {}
		if(!Object.isArray(ret)) return false;
		if(ret.length == 0) return false;
		var _flag = false;
		ret.each(function(item) {
			if(!_flag && item.star != 0) _flag = true;
		});
		if(_flag) return false;
		this.multiStar.id = ret[0].thread;
		var _el = $('tr_' + ret[0].thread), _s = _el.getElementsByTagName('td'),
		_img = this.multiStar.imgel = _s[4].firstChild, _sub = this.multiStar.subel = _s[5].firstChild, _index = 0;
		if(!_img || !_sub) return false;
		var self = this;
		this.multiStar.timer = setInterval(function() {
			try {
				if(!self.multiStar.star[_index]) {
					self.stopStar();
					_index = 0;
					try {
						arguments.callee();
					} catch(e) {}
					return false;
				}
				self.setStarClass(_img, self.multiStar.star[_index]);
				// _img.src = MailConst.ALL + self.multiStar.img[_index];
				_img.title = self.multiStar.title[_index];
				_sub.style.color = self.multiStar.color[_index];
				_index ++;
			} catch(e) {}
		}, 2000);
	},
	stopStar: function() {
		if(this.multiStar.timer) {
			clearInterval(this.multiStar.timer);
			this.multiStar.timer = null;
		}
	},
	setStarClass: function(el, classname) {
		this.multiStar.star.each(function(item) {
			try {
				Element.removeClassName(el, item);
			} catch(e) {}
		});
		Element.addClassName(el, classname);
	},
	
	// 用setInterval监听滚动
	listenPos: function() {
		var self = this;
		try {
			this.ptimer = setInterval(function() {
				self.scrollPos = DOM.sohuMailMain.scrollTop;
			}, 100);
		} catch(e) {}
	},
	stopListenPos: function() {
		try {
			if (this.ptimer) {
				clearInterval(this.ptimer);
				this.ptimer = null;
			}
		} catch(e) {}
	},
	
	// 设置用户正在读的一封信的箭头
	setUserArrow: function(id) {
		if(!id) return false;
		var _t = $('tr_' + id);
		if(!_t) return false;
		try {
			_t.firstChild.firstChild.className = 'am icon_arrow';
		} catch(e) {}
	},
	
	_format: function(list) {
		var _str = [], _str_normal = [];
		if(!list || list.length == 0) {
			return {format: [], normal: []};
		}
		list.each(function(_item) {
			_item = formatSysAccount(_item);
			var _name = _item[0], _nn = _item[1];
			if (_name && _name != '') {
				if(_name.include(' ')) {
					var _n = _name.split(' ');
					_str.push(['<span title="', _nn, '">', _n[0], '</span>'].join(''));
				} else {
					_str.push(['<span title="', _nn, '">', _name, '</span>'].join(''));
				}
				if(_nn && _nn != '') _str_normal.push(['\'', _name, '\'\<', _nn, '\>'].join(''));
			} else if(_nn && _nn != '') {
				if(_nn.include('@')) {
					var _nne = _nn.split('@');
					_nn.include(UserSohuID) ? _str.push(['<span title="', '">我</span>'].join(_nn)) : _str.push(['<span title="', _nn, '">', _nne[0], '</span>'].join(''));
				} else {
					_str.push(['<span title="', _nn, '">', _nn, '</span>'].join());
				}
				_str_normal.push(_nn);
			}
		});
		return {format: _str, normal: _str_normal};
	},
	
	// 格式化会话的参与者在列表界面的显示格式
	formatConferenceActor: function(item, isto) {
		var _from = item.envelope.from, _from_unread = item.envelope.from_after_1st_unread, adds = '';
		if(isto) {
			_from = item.envelope.to;
			_from_unread = [];
		}
		
		// item['rowids'].length > 1 ? ' <span style="font-weight:normal;"> (' + item['rowids'].length + ')</span>' : '';
		var _f1 = this._format(_from), _f2 = this._format(_from_unread);
		var _str = _f1.format, _str_unread = _f2.format;
		var _normal = _f1.normal.concat(_f2.normal);
		var __d = '<span style="font-weight:normal;font-size:10pt;">, </span>', __s = '<span style="font-weight:normal;font-size:10pt;"> ... </span>';
		if(_str.length > 0 && _str_unread.length > 0) {
			// 如果未读的发件人数大于2，那么只显示两个未读的发件人地址，已读地址显示一个
			if(_str_unread.length > 2) {
				if(_str.length > 1) {
					adds = ['<span style="font-weight:normal;">', _str[0], __s, '</span><span>', _str_unread[0], __s, _str_unread[_str_unread.length-1], '&nbsp; </span>'].join('');
				} else {
					adds = ['<span style="font-weight:normal;">', _str[0], __d, '</span><span>', _str_unread[0], __s, _str_unread[_str_unread.length-1], '&nbsp; </span>'].join('');
				}
			} else if(_str_unread.length == 2) {
				if(_str.length > 1) {
					adds = ['<span style="font-weight:normal;">', _str[0], __s, '</span><span>', _str_unread[0], __d, _str_unread[1], '&nbsp; </span>'].join('');
				} else {
					adds = ['<span style="font-weight:normal;">', _str[0], __d, '</span><span>', _str_unread[0], __d, _str_unread[1], '&nbsp; </span>'].join('');
				}
			} else {
				if(_str.length > 2) {
					adds = ['<span style="font-weight:normal;">', _str[0], __s, _str[_str.length-1], __d, '</span><span>', _str_unread[0], '&nbsp; </span>'].join('');
				} else {
					adds = ['<span style="font-weight:normal;">', _str.join(__d), __d, '</span><span>', _str_unread[0], '&nbsp; </span>'].join('');
				}
			}
		} else if(_str.length > 0) {
			if(_str.length > 3) {
				adds = ['<span style="font-weight:normal;">', _str[0], __s, _str[_str.length-2], __d, _str[_str.length-1], '</span>'].join('');
			} else {
				adds = ['<span style="font-weight:normal;">', _str.join(__d), '</span>'].join('');
			}
		} else if(_str_unread.length > 0) {
			if(_str_unread.length > 3) {
				adds = ['<span>', _str_unread[0], __s, _str_unread[_str_unread.length-2], __d, _str_unread[_str_unread.length-1], '</span>'].join('');
			} else {
				adds = ['<span>', _str_unread.join(__d), '</span>'].join('');
			}
		}
		/*
		var _new_normal = [];
		_normal.each(function(item) {
			if(!_new_normal.include(item)) _new_normal.push(item);
		});
		_new_normal = _new_normal.join(', ');
		*/
		// var _new_normal = _normal;
		return {
			f: adds == '' ? '未知邮件地址' : adds,
			n: _normal
		};
	},
	
	// 创建列表显示元素
	createItemList: function(item) {
		var ienv = item.envelope,
			addr_first_unread = ienv.from_after_1st_unread[0], 
			_isto = this.folder == 3 ? true : false,
			__send = this.formatConferenceActor(item, _isto), 
			// __send = {f:'test:addr',n:'test'},
			send_addr = __send.f, 
			send_addr_title = __send.n, 
			isread = item['unread'] > 0 ? 'noread' : 'isread',
			subject = (ienv['subject'] && ienv['subject'].strip() != '') ? ienv['subject'].stripTags() : '无标题';
		if(this.folder == -2) subject = '[' + this._F[item['folder']] + '] ' + subject;
		var attachment = item['atts'].length > 0 ? '<span class="am upload-fileicon"></span>' : '';
		var conf_num = item['rowids'].length > 1 ? ' <span style="font-weight:normal;"> (' + item['rowids'].length + ')</span>' : '';
		try {
			var _from = ienv.from_after_1st_unread.length > 0 ?
						ienv.from_after_1st_unread[0][1] : 
						ienv.from[0][1];
		} catch(e) {
			var _from = '';
		}
		var _is_sys_account = getSysAccount(_from);
		var conf_icon = _is_sys_account ? _is_sys_account.icon : item['rowids'].length > 1 ? (item['unread'] > 0 ? 'icon_conference' : 'icon_conference_read') : (item['unread'] > 0 ? 'icon_close' : 'icon_open');
		var conf_prompt = item['rowids'].length > 1 ? (_is_sys_account ? '这是一组系统邮件' : '这是一组会话邮件') : (_is_sys_account ? '这是一封系统邮件' : '这是一封普通邮件');
		conf_icon = 'am ' + conf_icon;
		var c = ['<tr id="tr_', item["thread"], '" class="', isread, '"><td><div></div></td>',
			'<td><input name="" type="checkbox" class="conference_item" value=""></td>'+
			'<td><img title="', conf_prompt,'" class="', conf_icon, '" src="', MailConst.ALL, '/spacer.gif" /></td>'+
			'<td><div style="margin-left:4px;">', attachment, '</div></td>'+
			'<td><div>', send_addr, conf_num, '</div></td>'+
			'<td style="cursor:pointer;"><span star="', item['star'], '" title="', this.multiStar.title[item.star], '" class="am s_star ', this.multiStar.star[item.star], '"></span></td>'+
			'<td style="cursor:pointer;"><div cid="', item["thread"], '" style="margin-left:8px;color:', (item.star > 0 ? this.multiStar.color[item.star] : (item.unread > 0 && _is_sys_account) ? _is_sys_account.color : ''), ';">',
			subject,
			'</div></td>'+
			'<td><div class="date-fmt"><span>', item['envelope']['display_date'][0], '</span></div></td>'+
			'</tr>'
		].join('');
        return c;
	},
	
	createSubHead: function(ret) {
        // ret.totalCount = 100;
		this.currentTotal = Math.abs(ret[0] && ret[0]['total_count'] ? ret[0]['total_count'] : this.getFolderItem(this.folder).thread_total);
        var str = [];
        var scount = ((this.page-1) * PAGE_CAPACITY) + 1;
        var ecount = (this.page * PAGE_CAPACITY) < this.currentTotal ? (this.page * PAGE_CAPACITY) : this.currentTotal;
        var cmcount = [scount, '-', ecount].join('');
        var mailnum = this.currentTotal > 0 ? ['第 <font id="spMailRange">', cmcount, '</font> 封，共 <font id="spMailCount">', this.currentTotal, '</font> 个会话'].join('') : '共 <font id="spMailCount"> 0 </font> 个会话';
        if (this.folder > -5) {
		str.push('<tr class="top_tr"><td>&nbsp;</td><td><input id="conference_all" class="conference_all" name="" type="checkbox" /></td><td colspan=3> 全选 / 取消全选 </td><td colspan=3><div style="float:right;text-align:right;"><span style="margin-right:16px;_margin-right:32px;">'+ mailnum +'</span></div></td></tr>');
        }else{
		str.push(mailStarList.get_list_pre(mailnum));
        }
        return str.join("");
    },
	
	createMessageInfo: function(msg){
		if(!msg || msg == '') return false;
		Tips.show(msg, 5);
		try {
			messageInfo = '';
		} catch(e) {}
    },
	
	// 操作栏的元素
	// 创建分类button之间的分割块
	createSprEL: function() {
		return '<div class="f-lf"><div class="bt-sprt"></div></div>';
	},
	
	_bt_m_evt: function(_os, _os_over, _os_down) {
		return 'onmouseover="this.className=\''+ _os_over +'\'" onmouseout="this.className=\''+ _os +'\'" onmousedown="this.className=\''+ _os_down +'\'" onmouseup="this.className=\''+ _os_over +'\'"';
	},
	
	// 永久删除
	createDeleteEL: function() {
		var _f = arguments[0] ? 'bt-first' : '',
			_os = 'a-bg bt-common bt-4 '+ _f;
		return '<div class="f-lf s_delete"><div class="'+ _os +'"><div class="a-bg inner"> 永久删除 </div></div></div>';
	},
	// 删除
	createDelEL: function() {
		var _f = arguments[0] ? 'bt-first' : '',
			_os = 'a-bg bt-common bt-2 '+ _f;
		return '<div class="f-lf s_delt"><div class="'+ _os +'"><div class="a-bg inner"> 删  除 </div></div></div>';
	},
	// 反删除
	createUnDelEL: function() {
		var _f = arguments[0] ? 'bt-first' : '',
			_os = 'a-bg bt-common bt-2 '+ _f;
		return '<div class="f-lf s_undelt"><div class="'+ _os +'"><div class="a-bg inner"> 还  原 </div></div></div>';
	},
	// 移动
	createMoveEL: function() {
		var _f = arguments[0] ? 'bt-first' : '',
			_os = 'a-bg bt-common bt-3 '+ _f;
		return '<div class="f-lf s_move"><div class="'+ _os +'"><div class="a-bg inner"><span> 移  至 </span><b class="a-bg bt-arrow-down"></b></div></div></div>';
	},
	// 垃圾举报
	createSpamEL: function() {
		var _f = arguments[0] ? 'bt-first' : '',
			_os = 'a-bg bt-common bt-5 '+ _f;
		return '<div class="f-lf s_spam"><div class="'+ _os +'"><div class="a-bg inner"> 举报并清除 </div></div></div>';
	},
	// 非垃圾邮件
	createUnspamEL: function() {
		var _f = arguments[0] ? 'bt-first' : '',
			_os = 'a-bg bt-common bt-5 '+ _f;
		return '<div class="f-lf s_unspam"><div class="'+ _os +'"><div class="a-bg inner"> 非垃圾邮件 </div></div></div>';
	},
	// 标记为已读未读
	createMkEL: function() {
		var _f = arguments[0] ? 'bt-first' : '',
			_os = 'a-bg bt-common bt-3 '+ _f;
		return '<div class="f-lf s_mark_unread"><div class="'+ _os +'"><div class="a-bg inner"><span> 标  记 </span><b class="a-bg bt-arrow-down"></b></div></div></div>';
	},
	// 已删除、垃圾邮件夹中的清空
	createClearEL: function() {
		var _f = arguments[0] ? 'bt-first' : '',
			_os = 'a-bg bt-common bt-2 '+ _f;
		return '<div class="f-lf s_clear_trash"><div class="'+ _os +'"><div class="a-bg inner"> 清  空 </div></div></div>';
	},
	createFirstPageEL: function() {
		var _s = arguments[0] ? 'lk-enable lk-disable' : 'firstpage lk-enable',
			_l = arguments[0] ? ' ' : ' role="link" tabindex="0" ';
		return '<span'+ _l +'class="'+ _s +'"> 首页 </span>';
	},
	createPrevPageEL: function() {
		var _s = arguments[0] ? 'lk-enable lk-disable' : 'prevpage lk-enable',
			_l = arguments[0] ? ' ' : ' role="link" tabindex="0" ';
		return '<span'+ _l +'class="'+ _s +'"> 上一页 </span>';
	},
	createNextPageEL: function() {
		var _s = arguments[0] ? 'lk-enable lk-disable' : 'nextpage lk-enable',
			_l = arguments[0] ? ' ' : ' role="link" tabindex="0" ';
		return '<span'+ _l +'class="'+ _s +'"> 下一页 </span>';
	},
	createEndPageEL: function() {
		var _s = arguments[0] ? 'lk-enable lk-disable' : 'endpage lk-enable',
			_l = arguments[0] ? ' ' : ' role="link" tabindex="0" ';
		return '<span'+ _l +'class="'+ _s +'"> 末页 </span>';
	},
	createSelPageEL: function(p) {
		var _os = 'am select-arrow selpage'
		return '<div id="sel" class="f-lf sel-area"><div class="f-rt"><div class="f-lf txt">转到第</div><div class="selectc"><div class="select-text" style="width:30px;">'+ p +'</div><div class="'+ _os +'"></div></div><div class="f-lf txt">页</div></div></div>';
	},
	
	createRtEL: function() {
		return '<div class="f-lf lk-rt s_rt"><div class="inner"><< 返  回</div></div>';
	},
	// 回复
	createReplyEL: function() {
		var _f = arguments[0] ? 'bt-first' : '',
			_os = 'a-bg bt-common bt-2 '+ _f;
		return '<div class="f-lf s_rp"><div class="'+ _os +'"><div class="a-bg inner"> 回  复 </div></div></div>';
	},
	// 回复全部
	createReplyAllEL: function() {
		var _f = arguments[0] ? 'bt-first' : '',
			_os = 'a-bg bt-common bt-4 '+ _f;
		return '<div class="f-lf s_rpall"><div class="'+ _os +'"><div class="a-bg inner"> 回复全部 </div></div></div>';
	},
	createForwardEL: function() {
		var _f = arguments[0] ? 'bt-first' : '',
			_os = 'a-bg bt-common bt-2 '+ _f;
		return '<div class="f-lf s_fw"><div class="'+ _os +'"><div class="a-bg inner"> 转  发 </div></div></div>';
	},
	createPrevEL: function() {
		var _s = arguments[0] ? 'lk-enable lk-dist lk-disable' : 's_prev lk-enable lk-dist',
			_l = arguments[0] ? ' ' : ' role="link" tabindex="0" ';
		return '<span'+ _l +'class="'+ _s +'">上一封</span>';
	},
	createNextEL: function() {
		var _s = arguments[0] ? 'lk-enable lk-dist lk-disable' : 's_next lk-enable lk-dist',
			_l = arguments[0] ? ' ' : ' role="link" tabindex="0" ';
		return '<span'+ _l +'class="'+ _s +'">下一封</span>';
	},
	// 普通模式中读信的打印、源文件、下载邮件功能
	createPtEL: function() {
		var _os = 'a-bg bt-common bt-2';
		return '<div class="f-lf s_print"><div class="'+ _os +'"><div class="a-bg inner"> 打  印 </div></div></div>';
	},
	createScEL: function(url) {
		var _os = 'a-bg bt-common bt-3';
		return '<div class="f-lf"><div class="'+ _os +'"><div class="a-bg inner"><a href="'+ url +'" target="_blank"> 源文件 </a></div></div></div>';
	},
	createDldEL: function(url) {
		var _os = 'a-bg bt-common bt-4';
		return '<div class="f-lf"><div class="'+ _os +'"><div class="a-bg inner"><a href="'+ url +'" target="_blank"> 下载邮件 </a></div></div></div>';
	},
	
	
	clearMailList: function() {
		if(DOM.mailList.childNodes.length > 0) {
			try {
				
			} catch(e) {}
		}
	},
    getMailRead: function(id, is_rsh) {
		if(!id) return;
		var _params = {
			id: id,
			folder: this.folder
		};
		this.currentCid = id;
		var _get_ = function() {
			var _sf = arguments.callee;
			var _ed = arguments[0];
			this.cacheList.each(function(item, index) {
				if(item.thread == id) {
					if(this.cacheList[index+1]) {
						NEXT_ID = this.cacheList[index+1].thread;
					} else {
						NEXT_ID = null;
						// 用（PAGE_CAPACITY - 1）来进行判断，考虑到读会话界面的删除当前会话的状况
						if (this.cacheList.length >= (PAGE_CAPACITY - 1) && !_ed) {
							var params = {
								folder: this.folder,
								start: this._next_page * PAGE_CAPACITY,
								length: PAGE_CAPACITY
							};
							conversation_list(params, function(ret){
								if (Object.isArray(ret)) {
									this.cacheList = this.cacheList.concat(ret);
									if(ret.length == 0) {
										_sf.apply(this, [true]);
									} else {
										this._next_page++;
										_sf.apply(this);
									}
								}
							}.bind(this));
							return false;
						}
					}
					if(this.cacheList[index-1]) {
						PREV_ID = this.cacheList[index-1].thread;
					} else {
						PREV_ID = null;
						if (this._prev_page != null && this._prev_page >= 0) {
							var params = {
								folder: this.folder,
								start: this._prev_page * PAGE_CAPACITY,
								length: PAGE_CAPACITY
							};
							conversation_list(params, function(ret){
								if (ret.length != 0) {
									this.cacheList = ret.concat(this.cacheList);
									this._prev_page--;
									_sf.apply(this);
								}
							}.bind(this));
							return false;
						}
					}
					if(this.folder == -2) this.cacheList = this.delCinList(index, this.cacheList);
					var _thread_cache = this.getThreadCache(_params.id, this.folder);
					if (_thread_cache && _thread_cache.length > 0) {
						this.getMailReadCallback(is_rsh, _thread_cache);
					} else {
						conversation_read(_params, this.getMailReadCallback.bind(this, is_rsh));
					}
				}
			}.bind(this));
		}.bind(this);
		// 清除掉读信界面或者草稿界面的多媒体编辑器（fix ie6 bug）
		try {
			for(var key in mailConference._editor) {
				mailConference._editor[key].destroy();
			}
			mailConference._editor = {};
		} catch(e) {}
		_get_();
    },
	
	// 从列表缓存中删掉一封会话
	delCinList: function(index, list) {
		this.delConference = list[index];
		return list.slice(0, index).concat(list.slice(index+1));
	},
	
	getMailReadCallback: function(is_rsh, ret) {
		if(Object.isArray(ret) && ret.length > 0) {
			this.searchApply = arguments[2];
			this.currentConference = ret;
			this.currentDraft = [];
			
			if(!this.hasThreadCache(ret[0].thread, this.folder) && !this.searchApply && this.folder > -4) {
				// this.searchApply --> 是否由搜索的结果页面过来，如果是搜索，那么不对会话作缓存了，因为搜索出会话的结果并不是整个会话，而只是和搜索相关的邮件才会返回
				this.setThreadCache(ret, ret[0].thread, this.folder);
			}
			
			// 重新组织返回的会话数据（主要是为了处理当前会话可能最后几封有连续出现deleted属性的状况）
			var _new_ret = [];
			this.tmpConference = [];
			ret.each(function(item) {
				if(item.deleted && item.deleted == 1) return;
				_new_ret.push(item);
				this.tmpConference.push({
					id: item.rowid,
					show: item.display ? true : false
				});
			}.bind(this));
			this._last_id = _new_ret[_new_ret.length-1].rowid;
			var _title = _new_ret[0].envelope.subject.stripTags();
			_title = _title != '' ? _title : '无标题';
			var html = [];
			var _rmb1 = $('read_mail_bar1'), _drc = $('dialog_read'), _rmb2 = $('read_mail_bar2');
			
			if (!_rmb1 && !_drc && !_rmb2) {
				var c = new Template(mailReadTemplate).evaluate({
					read_width: 'width:' + (getRightPanelWidth() - staticValue.rightAdsWidth - getMainSpaceWidth() - 1) + 'px;',
					read_style: 'content dialog_read',
					read_isads: (staticValue.rightAdsWidth == 0 ? 'display:none;' : ''),
					read_ads1: (staticValue.rightAdsWidth == 0 ? '' : readright1),
					read_ads2: (staticValue.rightAdsWidth == 0 ? '' : readright2)
				});
				DOM.readMail.innerHTML = c;
				_rmb1 = $('read_mail_bar1'), _drc = $('dialog_read'), _rmb2 = $('read_mail_bar2');
			} else {
				_drc.className = 'content dialog_read';
			}
			
			html.push('<div class="dialog_title"><div style="margin:auto 8px;width:60%;float:left;">'+ _title +'</div>'
					+'<div style="float:right;">'
					+'<div style="float:left;font-weight:normal;font-size:12px;margin-right:10px;"><span style="">共 ' + _new_ret.length + ' 封</span></div>'
					// +'<div id="expand_button" style="float:left;cursor:text;"><input type="button" '+ (_new_ret.length == 1 ? 'disabled=true' : '') +' tid="'+ _new_ret[0].thread +'" class="am yes '+ (_new_ret.length > 1 ? 's_expand_all' : '') +'" style="cursor:pointer;margin-top:3px;" value="全部展开" /><input type="button" '+ (_new_ret.length == 1 ? 'disabled=true' : '') +' tid="'+ _new_ret[0].thread +'" class="am yes '+ (_new_ret.length > 1 ? 's_shrink_all' : '') +'" style="cursor:pointer;margin-top:3px;display:none;" value="全部折叠" /></div>'
					+'<div id="expand_button" style="float:left;margin-right:10px;"><span tid="'+ _new_ret[0].thread +'" class="dialog_expand '+ (_new_ret.length == 1 ? 'dialog_expand_disable ' : '') + (_new_ret.length > 1 ? 's_expand_all' : '') +'" style="margin-top:3px;">全部展开</span><span tid="'+ _new_ret[0].thread +'" class="dialog_expand '+ (_new_ret.length == 1 ? 'dialog_expand_disable ' : '') + (_new_ret.length > 1 ? 's_shrink_all' : '') +'" style="margin-top:3px;display:none;">全部折叠</span></div>'
					+'</div>'
					+'</div>');
			var _first_unread_id = 0;
			// 如果有系统邮件，或者自己发出的邮件，就不显示垃圾举报的按钮了
			var _is_sys = false;
			try {
				_new_ret.each(function(item, index) {
					var _adl = [].concat(item.envelope.from_after_1st_unread).concat(item.envelope.from);
					if(!_is_sys) {
						_adl.each(function(__im) {
							if(getSysAccount(__im[1])) _is_sys = true;
						});
					}
					// if (item.deleted && item.deleted == 1) return false;
					if (item.have_read == 0 && _first_unread_id == 0) 
						_first_unread_id = item.rowid;
					// 如果当前信件存在，并且他的下一封信件是针对他的回复或者转发（next original id == rowid）
					if ((_new_ret[index + 1] && _new_ret[index + 1].folder == 2) && (_new_ret[index + 1]['envelope']['original_id'] == item.rowid)) {
						html.push(this.createItemMail(item, this.createItemDraft(_new_ret[index + 1], item)));
						return;
					}
					// 如果当前信件是一封草稿，并且这封草稿作为单独存在，和他之前的信件没有任何的关联
					if ((index == 0 || (_new_ret[index - 1] && item['envelope']['original_id'] != _new_ret[index - 1].rowid)) && item.folder == 2) {
						html.push(this.createItemMail(item, this.createItemDraft(item), true));
						return;
					}
					// 如果是最后一封信件，并且不是草稿
					if (index == _new_ret.length - 1 && item.folder != 2) {
						html.push(this.createItemMail(item, true, false, true));
						return;
					}
					// 最后一封信件有可能是delete状态，那么他的前一封就是最后要显示的信件(deleted这个属性会不会可能出现在连续两封的信件中呢)
					
					// 排除以上所有的可能，如果当前这封信件不是草稿
					if (item.folder != 2) 
						html.push(this.createItemMail(item));
				}.bind(this));
			} catch(e) { }
			hiddenAllPanel();
			_drc.innerHTML = html.join('');
			DOM.readMail.show();
			changePanel('readMail', this.folder);
			
			// 如果会话中只有一封信件
			if(_new_ret.length == 1 && _new_ret[0].folder != 2) {
				this.isHeadInfoShow(this._last_id);
			}
			
			var _op = [];
			_op.push('<div class="l-area rd">');
			_op.push(this.createRtEL());
			_op.push(this.createDeleteEL(true));
			if (this.folder != 2 && this.folder != 4 && this.folder != 5) {
				_op.push(this.createDelEL());
				if(!_is_sys) _op.push(this.createSpamEL());
			}
			if(this.folder != 2 && this.folder == 5) _op.push(this.createUnspamEL());
			_op.push(this.createSprEL());
			if (this.folder != 2 && this.folder != 3) _op.push(this.createMoveEL());
			_op.push('</div>');
			_op.push('<div class="r-area">');
			if(!PREV_ID && !NEXT_ID) {
				_op.push(this.createPrevEL(true));
				_op.push(this.createNextEL(true));
			} else if(!PREV_ID) {
				_op.push(this.createPrevEL(true));
				_op.push(this.createNextEL());
			} else if(!NEXT_ID) {
				_op.push(this.createPrevEL());
				_op.push(this.createNextEL(true));
			} else {
				_op.push(this.createPrevEL());
				_op.push(this.createNextEL());
			}
			_op.push('</div>');
			var _opht = _op.join('');
			_rmb1.innerHTML = _opht;
			_rmb2.innerHTML = _opht;
			
			if(this.currentDraft.length > 0) {
				this._upload = {};
				this._editor = {};
				this.createItemDraftEditor(this.currentDraft);
			}
			var _unread_rowid = [];
			this.currentConference.each(function(item) {
				if(!item.have_read) _unread_rowid.push(item.rowid);
				if(!item.display || item.display == '' || item.hidedisplay) return false;
				try {
					var _cif = $('content_info_' + item.rowid);
					if (_cif) {
						if (item.maximum && item.maximum != '') {
							_cif.innerHTML = '<iframe id="maximum_'+ item.rowid +'" onload="resizeMailContent(\'maximum_'+ item.rowid +'\');" src="./download/'+ item.maximum +'.7" style="width:100%;height:800px;border:0px" frameborder=0></iframe>';
						} else {
							_cif.innerHTML = item.display;
						}
					}
				} catch(e) {}
			}.bind(this));
			
			// 将未读的邮件设置为已读
			try {
				if (_unread_rowid.length > 0) this.setRead(_unread_rowid);
			} catch(e) {}
			
			// 重新设置会话的缓存内容
			try {
				this.resetThreadCache(this.currentConference[0].thread, this.folder);
			} catch(e) {}
			
			try {
				if (_first_unread_id != 0) {
					// 留出80个像素，将第一封未读邮件的头部区域显示出来
					var _el_t = Position.cumulativeOffset($('dialog_item_' + _first_unread_id))[1] + 80, _d_h = document.body.clientHeight;
					if(_el_t > _d_h) {
						DOM.sohuMailMain.scrollTop = (_el_t - 300);
					} else {
						DOM.sohuMailMain.scrollTop = 0;
					}
				} else {
					DOM.sohuMailMain.scrollTop = 0;
				}
			} catch(e) {}
			
			// 发现会话中需要 “显示引用文字” 的元素
			/*
			try {
				var _quote_list = $A(DOM.readMail.getElementsByClassName('sohu_quote'));
				_quote_list.each(function(item) {
					if(item.innerHTML.stripTags().blank()) return false;
					this.isShowQuote(item);
					Element.hide(item);
				}.bind(this));
			} catch(e) {}
			*/
			
			try {
				this.isShowExpand();
			} catch(e) {}
			
			// 读信页面右侧的广告
			try {
				rightAdsPoll('right_ads1', 'right_ads2');
			} catch(e) {}
			
			try {
				var _exec_callback = this.read_mail_callback_exec;
				if(_exec_callback && typeof _exec_callback == 'function') {
					_exec_callback();
					this.read_mail_callback_exec = null;
				}
			} catch(e) {}
			
			try {
				deleteLoadPage();
			} catch(e) {}
			
			if (!is_rsh) {
				var exec_func = this.searchApply ? 'mailSearch.getMailRead' : 'mailConference.getMailRead';
				addAjaxHistory('readMail_' + this.currentConference[0].thread, exec_func + '('+ this.currentConference[0].thread +', true)', _title);
			}
		}
	},
	
	isShowExpand: function() {
		var self = this;
		var _t = setTimeout(function() {
			clearTimeout(_t);
			_t = null;
			var _flag = true, _f = 0;
			self.tmpConference.each(function(item, index) {
				if(index == (self.tmpConference.length - 1)) return false;
				if(item.show) _f++;
			});
			if(_f == (self.tmpConference.length - 1)) _flag = false;
			self.showExpand(_flag);
		}, 100);
	},
	
	setShowExpand: function(id, show) {
		this.tmpConference.each(function(item) {
			if(item.id == id) item.show = show;
		});
	},
	
	// 显示展开/折叠按钮
	showExpand: function(show) {
		var epb = $('expand_button').getElementsByTagName('span');
		if(show) {
			Element.show(epb[0]);
			Element.hide(epb[1]);
		} else {
			Element.hide(epb[0]);
			Element.show(epb[1]);
		}
	},
	
	// 展开/折叠会话中所有的信件
	operateAllMails: function(thread, operate) {
		var self = this, _ope = operate == 'expand' ? 'show' : 'hide';
		var _shrink = function(mails) {
			try {
				mails.each(function(item) {
					try {
						if (!mailRead.readMailCache['mail_' + item.rowid]) {
							mailRead.readMailCache['mail_' + item.rowid] = item;
						}
						try {
							self.isShow(item.rowid, _ope);
						} catch(e) {}
					} catch(e) {}
				}.bind(self));
			} catch(e) {}
		};
		try {
			if(!this.conferenceAllMails['thread_' + thread]) {
				var params = {
					id: thread,
					folder: this.folder,
					expand: 1
				};
				conversation_read(params, function(ret) {
					if (!ret || !Object.isArray(ret)) return false;
					if (ret.length == 0) return false;
					this.conferenceAllMails['thread_' + thread] = ret;
					_shrink(ret);
				}.bind(this));
			} else {
				_shrink(this.conferenceAllMails['thread_' + thread]);
			}
		} catch(e) {}
	},
	
	// 是否显示引用信息的元素事件
    isShowQuote: function(el){
        try {
            if (el.previousSibling.className == 's_show_blockquote') 
                return false;
        } catch (e) {}
        var _div = document.createElement('div');
        _div.className = 's_show_blockquote';
        Element.setStyle(_div, {
            color: '#500050',
            fontSize: '9pt',
            cursor: 'pointer'
        });
        _div.innerHTML = '显示引用文字';
        Event.observe(_div, 'click', function(event){
            var _q = el;
            if (Element.visible(_q)) {
                Element.hide(_q);
                _div.innerHTML = '显示引用文字';
            } else {
                Element.show(_q);
                _div.innerHTML = '隐藏引用文字';
            }
        });
        Element.insert(el, {
            before: _div
        });
    },
	
	// 创建编辑草稿的编辑器、上传附件初始化
	// _invoke: 是否引用信件内容（适用于回复）
	// _file（是否显示附件）
	createItemDraftEditor: function(_current_draft, _no_content, _file) {
		this._tmp_atts = [];
		this._tmp_reply_atts = [];
		var dp = '';
		_current_draft.each(function(item, index) {
			dp = item.display;
			try {
				var _u = this._upload['u_' + item.rowid] = new MailUploadFile('upload_iframe_content_' + item.rowid, 'uploadInfoDIV_' + item.rowid);
				_u.init();
				_u.createForm();
			} catch(e) {}
			
			try {
				if(item.envelope.attach && item.envelope.attach.length > 0) this._tmp_atts.push(item);
				if(item.attach && item.attach.length > 0) this._tmp_reply_atts.push(item);
			} catch(e) { }
			try {
				if(!item.have_read) _unread_rowid.push(item.rowid);
			} catch(e) {}
			var self = this;
			var t = setTimeout(function() {
			 	clearTimeout(t);
				t = null;
				self._editor['e_' + item.rowid] = new HTMLEditor(['bold', 'justifyleft', 'fontselect', 'fontsizeselect', 'forecolor', 'insertimage', 'createlink', 'sign']);
				var _o = self._editor['e_' + item.rowid];
				_o.all[_o.all.length-1].click = function() {
					self._setSign(_o);
				};
				try {
					$('checkSign_' + item.rowid).onclick = function(){
						self._addSign(_o, this);
					};
				} catch(e) {}
				try {
					$('toggleEditor_' + item.rowid).onclick = function(){
						var _he = $('compose.mess1_' + item.rowid);
						var _te = $('compose.mess2_' + item.rowid);
						var _he_2_te = function() {
							_he.hide();
							_te.show();
							$('editor.mess2_' + item.rowid).value = self._editor['e_' + item.rowid].getContent().stripTags();
							$('user_sign_area_' + item.rowid).hide();
							$('toggleEditor_' + item.rowid).innerHTML = '切换为HTML';
							self._editor['e_' + item.rowid].is_text = true;
						};
						var _te_2_he = function() {
							_he.show();
							_te.hide();
							self._editor['e_' + item.rowid].setContent($('editor.mess2_' + item.rowid).value);
							$('user_sign_area_' + item.rowid).show();
							$('toggleEditor_' + item.rowid).innerHTML = '切换为纯文本';
							self._editor['e_' + item.rowid].is_text = false;
						};
						if(Element.visible(_he)) {
							_dialog.confirm({info: '将此邮件转换为纯文本将会遗失某些格式。您确定要继续吗？', click: function() {
								_he_2_te();
							}});
						} else {
							_te_2_he();
						}
					};
				} catch(e) {}
				_o.create('ineditor_' + item.rowid, function() {
					try {
						_o.setContent(dp);
						_o.setSelect(_o.c().document.body, 0, 0);
						_o.focus();
						_o.origin_content = _o.getContent();
					} catch(e) {}
				});
				try {
					var _a = self._autocomplete['a_' + item.rowid] = {};
					var _d = $('draft_' + item.rowid);
					var _alist = reAutoLists();
					_a['to'] = new AddressFilter('to_' + item.rowid, _d, _alist);
					_a['cc'] = new AddressFilter('wcc_' + item.rowid, _d, _alist);
					_a['bcc'] = new AddressFilter('wbcc_' + item.rowid, _d, _alist);
				} catch(e) {}
				try {
					var __uifr = $('upload_file_area_' + item.rowid);
					Element.setStyle(__uifr, {
						clear: 'left'
					});
				} catch(e) {}
			}, 0);
		}.bind(this));
		if(_file === false) return;
		if(this._tmp_atts.length > 0) {
			mail_save_att({}, function(ret) {
				this._tmp_atts.each(function(item) {
					var _t = [];
					var __attach = item.envelope.attach;
					ret.each(function(_item) {
						try {
							if (__attach.include(_item.id)) {
								_t.push(_item);
							}
						} catch(e) {}
					});
					
					try {
						this._upload['u_' + item.rowid].createInitInfo(_t);
					} catch(e) {}
				}.bind(this));
			}.bind(this));
		} else if(this._tmp_reply_atts.length > 0 && _current_draft.length == 1) {
			var params = {
				mail: _current_draft[0].rowid
			};
			mail_save_att(params, function(ret) {
				if(ret.length > 0) {
					mail_save_att({}, function(_ret) {
						var _tmp = [];
						_ret.each(function(_item) {
							if(ret.include(_item.id)) {
								_tmp.push(_item);
							}
						});
						if(this._upload['u_' + _current_draft[0].rowid])
							this._upload['u_' + _current_draft[0].rowid].createInitInfo(_tmp);
					}.bind(this));
				}
			}.bind(this));
		}
	},
	
	// 检查读会话页面中，当用户回复或转发一封会话时，编辑状态是否发生变化
	_editor_content_change: function() {
		var flag = false;
		try {
			if (arguments[0]) {
				if(!this._editor[arguments[0]]) return flag;
				if (this._editor[arguments[0]].origin_content != this._editor[arguments[0]].getContent()) 
					flag = true;
				return flag;
			}
		} catch(e) {
			console.log(e.message);
		}
		try {
			for (var key in this._editor) {
				if (!flag && this._editor[key].origin_content != this._editor[key].getContent()) 
					flag = true;
			}
		} catch(e) {
		}
		return flag;
	},
	
	_editor_content_check: function(mitem, callback) {
		try {
			if (this._editor_content_change(mitem)) {
				_dialog.confirm({
					info: '您的邮件正处于编辑状态，您确定要放弃吗？',
					click: function(event){
						callback();
					}
				});
				return false;
			}
		} catch(e) {
		}
		return true;
	},
	
	// 添加个性签名
	_setSign: function(editorObj) {
		if(!this._s_index) this._s_index = 0;
		var _append = function(psign) {
			var add_mail_sign = editorObj['c']().document.getElementById("addMailSign");
			var personal_sign = editorObj['c']().document.getElementById("personalSign");
			var image_sign = editorObj['c']().document.getElementById('imageSign');
			if (add_mail_sign && add_mail_sign != null) {
				if (!personal_sign) {
					var content = '';
					if (!image_sign) {
						content = "<br /><div id='personalSign' style='clear:both;color:#005BA2;margin-left:15px;'>" + psign + "</div>";
					} else {
						content = "<br /><div id='personalSign' style='clear:both;color:#005BA2;margin-left:15px;'>" + psign + "</div>";
					}
					var _div = document.createElement('div');
					_div.innerHTML = 'test';
					add_mail_sign.innerHTML += content;
				} else {
					personal_sign.innerHTML = psign;
				}
			} else {
				var currentSign = "<br /><br /><br /><br /><div id='addMailSign'> <br /><div id='personalSign' style='clear:both;color:#005BA2;margin-left:15px;'>" + psign + "</div></div>";
				editorObj['setContent'](editorObj['getContent']() + currentSign);
			}
		};
		if(!this.signlist) {
			_defun('/sign/act/RandomSign', 'post', {}, function(ret) {
				this.signlist = ret.signlist.split('|');
				if(!this.signlist[this._s_index]) this._s_index = 0;
				_append(this.signlist[this._s_index]);
				this._s_index ++;
			}.bind(this));
		} else {
			if(!this.signlist[this._s_index]) this._s_index = 0;
			_append(this.signlist[this._s_index]);
			this._s_index ++;
		}
	},
	
	// 添加签名
	_addSign: function(editorObj, checkObj) {
        if (checkObj.checked) {
            this.__add_sign(editorObj);
            checkObj.checked = true;
        } else {
            var add_mail_sign = editorObj['c']().document.getElementById("addMailSign");
            var image_sign = editorObj['c']().document.getElementById("imageSign");
            var text_sign = editorObj['c']().document.getElementById("textSign");
            if (add_mail_sign && add_mail_sign != null) {
                if (image_sign) {
                    image_sign.parentNode.removeChild(image_sign);
                }
                if (text_sign) {
                    text_sign.parentNode.removeChild(text_sign);
                }
            }
            checkObj.checked = false;
        }
	},
	__add_sign: function(editorObj) {
		if (!mailCfgClass.getProfileContent().signature|| mailCfgClass.getProfileContent().signature.strip() == "") {
			_dialog.alert({info: '您的签名为空，请先设置签名！'});
			return;
		}
		try {
			if(!mailCfgClass.getProfileContent().image_signature){
				var currentSign = "<br /><br /><br /><br /><div id='addMailSign'><br /><div id='textSign'>"
				+mailCfgClass.getProfileContent().signature+ "</div></div>";
			} else {
				if (mailCfgClass.getProfileContent().image_signature_name) {
					var currentSign = "<br /><br /><br /><br /><div id='addMailSign'><br /> <div id='imageSign'><img src="+SIGN_ROOT + "/" + mailCfgClass.getProfileContent().image_signature_name + ".jpg?"+Math.random()+"  style='width:148px;height:106px;margin: 15px 4px 8px 15px; float: left; display: inline;'/>"
					+"<div style='margin: 12px 28px 28px 10px; float: left;'>" +mailCfgClass.getProfileContent().signature
					+"</div></div><div style='clear:both;'></div></div>";
				}else{
					var currentSign = "<br /><br /><br /><br /><div id='addMailSign'><br /> <div id='imageSign'><img src='"+ MailConst.ALL+"/demo.jpg'   style='width:148px;height:106px;margin: 15px 4px 8px 15px; float: left; display: inline;'/>" 
					+"<div style='margin: 12px 28px 28px 10px; float: left;'>"+mailCfgClass.getProfileContent().signature+
					"</div></div></div>";
				}
			}
		} catch(e) {}
		var add_mail_sign = editorObj['c']().document.getElementById("addMailSign");
		var personal_sign = editorObj['c']().document.getElementById("personalSign");
		var text_sign = editorObj['c']().document.getElementById("textSign");
		var image_sign = editorObj['c']().document.getElementById("imageSign");
		var mail_content = editorObj['c']().document.getElementById("mailcontent");
		if (add_mail_sign && add_mail_sign != null) {
			try {
				if (!mailCfgClass.getProfileContent().image_signature) {
					if (!personal_sign) {
						add_mail_sign.innerHTML = "<br /><div id='textSign'>" + mailCfgClass.getProfileContent().signature+"</div>";
					}
					else {
						var content = "<div id='textSign'>"+mailCfgClass.getProfileContent().signature+ "<br /></div>";
						if(!text_sign) add_mail_sign.innerHTML = content + add_mail_sign.innerHTML;
					}
				} else {
					if (!personal_sign) {
						if (mailCfgClass.getProfileContent().image_signature_name) {
							add_mail_sign.innerHTML = "<br /> <div id='imageSign'><img src=" +SIGN_ROOT + "/" +  mailCfgClass.getProfileContent().image_signature_name +".jpg?"+Math.random()+ "  style='width:148px;height:106px;margin: 15px 4px 8px 15px; float: left; display: inline;'/>" +
							"<div style='margin: 12px 28px 28px 10px; float: left;'>" +
							mailCfgClass.getProfileContent().signature +
							"</div><div style='clear:both;'></div></div>";
						} else {
							add_mail_sign.innerHTML = "<br /> <div id='imageSign'><img src='" + MailConst.ALL + "/demo.jpg' style='width:148px;height:106px;margin: 15px 4px 8px 15px; float: left; display: inline;'/>" +
							"<div style='margin: 12px 28px 28px 10px; float: left;'>" +
							mailCfgClass.getProfileContent().signature +
							"</div></div>";
						}
					} else {
						var content='';
						if (mailCfgClass.getProfileContent().image_signature_name) {
							content = "<br /><div id='imageSign'><img src=" + SIGN_ROOT + "/" +mailCfgClass.getProfileContent().image_signature_name +".jpg?"+Math.random()+"  style='width:148px;height:106px;margin: 15px 4px 8px 15px; float: left; display: inline;'/>" +
							"<div style='margin: 12px 28px 28px 10px; float: left;'>" +
							mailCfgClass.getProfileContent().signature+
							"</div></div>";
							// Element.insert(Editor.c().document.getElementById("personalSign"), {before: content});
							if(!image_sign) add_mail_sign.innerHTML = content + add_mail_sign.innerHTML;
						}
						else {
							content = "<br /><div id='imageSign'><img src='" + MailConst.ALL + "/demo.jpg'   style='width:148px;height:106px;margin: 15px 4px 8px 15px; float: left; display: inline;'/>" +
							"<div style='margin: 12px 28px 28px 10px; float: left;'>" +
							mailCfgClass.getProfileContent().signature +
							"</div></div>";
						}
						//Element.insert(Editor.c().document.getElementById("personalSign"), {before: content});
					}
				}
			} catch(e) {}
		} else {
            if (mail_content) {
				Element.insert(mail_content, {
					before: currentSign
				});
			} else {
				editorObj['setContent'](editorObj['getContent']() + currentSign);
			}
		}
	},
	
	// 读一封会话中的菜单显示事件的绑定
	// 新版界面中不再需要每封信件的操作菜单，暂时先注释了
	/*
	bindMenuEvent: function(_item) {
		var _e = $('menu_info_' + _item.rowid);
		this._menu_event_list.push(_e);
		var self = this;
		var datalist = [
			{
				text: '<div style="float:left;margin-right:6px;width:20px;"><span class="am icon_delete" style="display:block;margin-top:1px;height:18px;"></span></div><div style="float:left;cursor:pointer;">删　　除</div>',
				onclick: function() {
					self.delMail([_item.rowid], 'del');
					return;
				}
			},
			{
				text: '<div style="float:left;margin-right:6px;width:20px;"><span class="am icon_del" style="display:block;margin-top:1px;height:18px;"></span></div><div style="float:left;cursor:pointer;">永久删除</div>',
				onclick: function() {
					self.delMail([_item.rowid], 'delete');
					return;
				}
			},
			{
				text: '<div style="float:left;margin-right:6px;width:20px;"><span class="am icon_mail" style="display:block;margin-top:1px;height:18px;"></span></div><div style="float:left;cursor:pointer;">源　文件</div>',
				onclick: function() {
					self.sourceMail(_item.mid);
					return;
				}
			},
			{
				text: '<div style="float:left;margin-right:6px;width:20px;"><span class="am icon_load" style="display:block;margin-top:1px;height:18px;"></span></div><div style="float:left;cursor:pointer;">下载邮件</div>',
				onclick: function() {
					self.downloadMail(_item.mid);
					return;
				}
			},
			{
				text: '<div style="float:left;margin-right:6px;width:20px;"><span class="am icon_print" style="display:block;margin-top:1px;height:18px;"></span></div><div style="float:left;cursor:pointer;">打　　印</div>',
				onclick: function() {
					self.printMail(_item.rowid);
					return false;
				}
			}
		];
		if (_e) {
			new Menu().init(_e, DOM.sohuMailMain, datalist, 'dialog_menu', true, null, true);
		}
	},
	*/
	/*
	getMenuList: function(item) {
		var self = this;
		return [
			{
				text: '<div style="float:left;margin-right:6px;width:20px;"><span class="am icon_delete" style="display:block;margin-top:1px;height:18px;"></span></div><div style="float:left;cursor:pointer;">删　　除</div>',
				onclick: function() {
					self.delMail([item.rowid], 'del');
					return;
				}
			},
			{
				text: '<div style="float:left;margin-right:6px;width:20px;"><span class="am icon_del" style="display:block;margin-top:1px;height:18px;"></span></div><div style="float:left;cursor:pointer;">永久删除</div>',
				onclick: function() {
					self.delMail([item.rowid], 'delete');
					return;
				}
			},
			{
				text: '<div style="float:left;margin-right:6px;width:20px;"><span class="am icon_mail" style="display:block;margin-top:1px;height:18px;"></span></div><div style="float:left;cursor:pointer;">源　文件</div>',
				onclick: function() {
					self.sourceMail(item.mid);
					self.downloadMail(item.mid);
					self.printMail(item.rowid);
					return;
				}
			},
			{
				text: '<div style="float:left;margin-right:6px;width:20px;"><span class="am icon_load" style="display:block;margin-top:1px;height:18px;"></span></div><div style="float:left;cursor:pointer;">下载邮件</div>',
				onclick: function() {
					self.downloadMail(item.mid);
					return;
				}
			},
			{
				text: '<div style="float:left;margin-right:6px;width:20px;"><span class="am icon_print" style="display:block;margin-top:1px;height:18px;"></span></div><div style="float:left;cursor:pointer;">打　　印</div>',
				onclick: function() {
					self.printMail(item.rowid);
					return false;
				}
			}
		];
	},
	*/
	
	// 释放列表页面编辑器、上传附件组建、自动输入框所占用的内存空间
	destroyEditMail: function(id) {
		try {
			if(this._editor['e_' + id]) {
				this._editor['e_' + id].destroy();
				this._editor['e_' + id] = null;
				delete this._editor['e_' + id];
			}
		} catch(e) {}
		try {
			if(this._upload['u_' + id]) {
				this._upload['u_' + id].destroy();
				this._upload['u_' + id] = null;
				delete this._upload['u_' + id];
			}
		} catch(e) {}
		try {
			if (this._autocomplete['a_' + id]) {
				for (var key in this._autocomplete['a_' + id]) {
					if (this._autocomplete['a_' + id][key]) {
						this._autocomplete['a_' + id][key].destroy();
						this._autocomplete['a_' + id][key] = null;
						delete this._autocomplete['a_' + id][key];
					}
				}
			}
		} catch(e) {}
	},
	
	// 在列表模式下编辑草稿的发送接口
	sendMail: function(rowid, is_save) {
		if(this.currentDraft.length == 0) return;
		try {
			mail_send_e.genuuid();
		} catch(e) {}
		var data = {};
		this.currentDraft.each(function(item) {
			if(item.rowid == rowid) data = item; 
		});
		var uf = [];
		this._upload['u_' + data.rowid].FILES_INFOS.each(function(item) {
			if(item.success) uf.push(item.id);
		});
		
		var _is_html = 1;
		if(this._editor['e_' + data.rowid].is_text) {
			var text_content = $('editor.mess2_' + data.rowid).value, html_content = text_content;
			_is_html = 0;
		} else {
			var html_content = this._editor['e_' + data.rowid].getContent(), text_content = html_content.stripTags();
			_is_html = 1;
		}
		
		var _from = [], _to = [], _cc = [], _bcc = [];
		data.envelope.from.each(function(item) {
			if(!item || !item[1]) return;
			_from.push(item[1]);
		});
		var _to_v = $('to_' + data.rowid).value, _cc_v = $('wcc_' + data.rowid).value, _bcc_v = $('wbcc_' + data.rowid).value, _subject_v = $('subject_' + data.rowid).value;
		
		// 格式化邮件地址
		_to_v = writemail.getSendEmail2ArrayList(_to_v, true);
		_cc_v = writemail.getSendEmail2ArrayList(_cc_v);
		_bcc_v = writemail.getSendEmail2ArrayList(_bcc_v);
		
		var orig_uid = data.envelope.from[0] ? data.envelope.from[0][1] : data.envelope.from_after_1st_unread[0][1];
		var _sb = mailCfgClass.getProfileContent().autosavesendmail ? 1 : 0;
		var _env = {
			attach: uf,
			thread: data.thread,
			original_id: data.rowid,
			draft_type: data.envelope.draft_type,
			message_id: data.message_id,
			references: data.envelope.references.concat(data.envelope.message_id).compact(),
			reply_to: data.envelope.reply_to.compact(),
			in_reply_to: [data.envelope.message_id].compact(),
			mail_followup_to: data.envelope.mail_followup_to.compact(),
			del_after_send: 1,
			save_after_send: 1,
			orig_uid: orig_uid,
			save_to_addressbook: _sb
		};
		var _send = is_save ? 0 : 1;
		if(_send && ExecFunc("receiverFilterBeforeSendMail",{to:_to_v,cc:_cc_v,bcc:_bcc_v})===false){
			return;
		}
		// 做一个判断，这个rowid是否是已经存在的一个草稿id,还是用户的回复或者转发，（如果是回复或者转发，这个id默认为0）
		var _rowid = 0;
		this.currentConference.each(function(item) {
			if(item.rowid == rowid && item.folder == 2) _rowid = rowid;
		});
		var params = {
			id: _rowid,
			is_send: _send,
			is_html: _is_html,
			subject: _subject_v,
			html: html_content,
			text: text_content,
			from: UserSohuID,
			to: _to_v.join(', '),
			cc: _cc_v.join(', '),
			bcc: _bcc_v.join(', '),
			env: Object.toJSON(_env),
			securityCode: mail_send_e.UUID,
			sendtime: mail_send_e._sendtime
		};
		
		var list_mail_addr = function(str) {
			str = decodeURI(str);
			if(str.blank()) return [];
			var a = str.split(',');
			if(a.length == 0 || a[0] == '') return [];
			a.each(function(item, index) {
				if(item.include('<') && item.include('>')) {
					var _i = item.indexOf('<');
					var tp1 = item.slice(0, _i).strip();
					if(tp1.startsWith('"') && tp1.endsWith('"')) {
						tp1 = tp1.slice(1, tp1.length-1);
					}
					var tp2 = item.substring(_i).strip();
					tp2 = tp2.slice(1, tp2.length-1);
					a[index] = [tp1, tp2];
				} else {
					a[index] = ['', item];
				}
			});
			return a;
		};
		var _mail = {};
		_mail = Object.extend(data, _mail);
		_mail.envelope.from = list_mail_addr(encodeURI(UserSohuID));
		_mail.envelope.to = list_mail_addr(encodeURI(_to_v));
		_mail.envelope.cc = list_mail_addr(encodeURI(_cc_v));
		_mail.envelope.bcc = list_mail_addr(encodeURI(_bcc_v));
		_mail.envelope.subject = _subject_v;
		_mail.envelope.attach = uf;
		_mail.attach = uf;
		_mail.display = html_content;
		_mail.folder = 3;
		var _callback = is_save ? this.saveMailCallback : this.sendMailCallback;
		var _failure_callback = is_save ? this.saveMailFailureCallback : this.sendMailFailureCallback;
		var _mail_cp = Object.clone(_mail);
		mail_send(params, _callback.bind(this, _mail_cp), _failure_callback.bind(this));
		try {
			// 清除掉所有列表缓存，和当前会话相关的缓存
			this.clearListCache();
			this.clearThreadCache(this.currentConference[0].thread, this.folder);
		} catch(e) {}
	},
	
	sendMailCallback: function(mail, ret) {
		if(!ret.is_success) {
			_dialog.alert({info: ret.message});
			return false;
		}
		try {
			this.destroyEditMail(mail.rowid);
		} catch(e) {}
		// remove之前存在的last_reply_textarea
		var _lrt = $('last_reply_textarea_id');
		if(_lrt) Element.remove(_lrt);
		var cel = $('draft_' + mail.rowid);
		var mcel = $('mail_info_' + mail.rowid);
		var mbody = $('dialog_item_' + mail.rowid);
		var _list = $('dialog_read').childNodes, _last_item = _list[_list.length-1];
		// var _orid = mail.rowid;
		var _orid = _last_item.id.split('_')[2];
		try {
			var _oel = $('option_info_title_' + _orid);
			/*
			Event.observe(_oel, 'click', function(event){
				eventStop(event);
				mailConference.isShow(_orid);
				return false;
			});
			*/
			Element.addClassName(_oel, 's_show_item');
			Element.setStyle(_oel, {
				cursor: 'pointer'
			});
		} catch(e) {}
		try {
			$('mail_info_' + _orid).removeAttribute('expand');
		} catch(e) {}
		try {
			mailConference.isShow(_orid, 'hide');
		} catch(e) {}
		// 这个新的rowid应该在后台生成返回，目前由前端暂时生成一个临时的
		this._last_id = mail.rowid = ret.id;
		this.currentConference = this.currentConference.concat(mail);
		var _ct = this.createItemMail(mail, true, false, true);
		Element.insert(_last_item, {after: _ct});
		var _y = Position.cumulativeOffset($(_last_item))[1] + $(_last_item).getHeight();
		DOM.sohuMailMain.scrollTop = _y;
		$('content_info_' + mail.rowid).innerHTML = mail.display;
		try {
			Element.insert(_last_item, {
				after: new Template(hintTemplate).evaluate({
					message: '信件发送成功！'
				})
			});
		} catch(e) {}
		try {
			Element.setStyle(_last_item.nextSibling, {
				marginTop: '16px'
			});
		} catch(e) {}
		try {
			Element.remove(cel);
		} catch(e) {}
		try {
			if (!mcel) Element.remove(mbody);
		} catch(e) {}
		
		try {
			var _t = setTimeout(function() {
				clearTimeout(_t);
				_t = null;
				Element.remove($('messageDiv'));
			}, 3000);
		} catch(e) {};
		
		// 绑定菜单的事件
		/*
		try {
			this.bindMenuEvent(mail);
		} catch(e) {}
		*/
		// 判断用户时候设置了自动保存新联系人，如果是，则将联系人信息自动保存
		try {
			var atsv = mailCfgClass.getProfileContent().autosavesendmail;
			if (atsv) {
				writemail.sendSuccSaveMailList(ret.save_list, true);
			}
		} catch(e) {}
		// 添加到最近联系人中
		try {
			var save_recent = ret.addr_list ? ret.save_list.concat(ret.addr_list) : ret.save_list;
			writemail.addRecentLists(save_recent);
		} catch(e) {}
		// 清除已发送列表的缓存
		try {
			this.clearListCache(3);
		} catch(e) {}
	},
	
	sendMailFailureCallback: function() {
		_dialog.alert({info: '信件发送失败！'});
	},
	
	// 在列表模式下保存草稿的接口
	saveMail: function(rowid) {
		this.sendMail(rowid, true);
	},
	
	saveMailCallback: function(mail, ret) {
		if(typeof ret == 'object') {
			var cel = $('draft_' + mail.rowid);
			Element.insert(cel, {before: new Template(hintTemplate).evaluate({message: '信件保存成功！'})});
			try {
				if(this._editor['e_' + mail.rowid]) {
					this._editor['e_' + mail.rowid].origin_content = this._editor['e_' + mail.rowid].getContent();
				}
			} catch(e) {}
			try {
				var _t = setTimeout(function() {
					clearTimeout(_t);
					_t = null;
					Element.remove($('messageDiv'));
				}, 3000);
			} catch(e) {};
		} else {
			_dialog.alert({info: '信件保存失败！'});
		}
		// 清除保存草稿列表的缓存
		try {
			this.clearListCache(2);
		} catch(e) {}
	},
	
	saveMailFailureCallback: function() {
		_dialog.alert({info: '信件保存失败！'});
	},
	
	deltDraftMail: function(id) {
		var self = this;
		var _rowid = 0;
		this.currentConference.each(function(item) {
			if(item.rowid == id && item.folder == 2) _rowid = id;
		});
		var mail_move_callback = function(ret) {
			try {
				Element.insert($('draft_' + id), {
					before: new Template(hintTemplate).evaluate({
						message: '操作成功！'
					})
				});
			} catch(e) {}
			try {
				/*
				if (self._editor['e_' + id]) {
					self._editor['e_' + id] = null;
					delete self._editor['e_' + id];
				}
				*/
				self.destroyEditMail(id);
				$('draft_' + id).hide();
			} catch(e) {}
			try {
				self.clearThreadCache(self.currentConference[0].thread, self.folder);
			} catch(e) {}
			try {
				var _t = setTimeout(function() {
					clearTimeout(_t);
					_t = null;
					var _div = $('messageDiv');
					if(_div) Element.remove(_div);
					var mcel = $('mail_info_' + id);
					var mbody = $('dialog_item_' + id);
					if (!mcel) {
						mbody && Element.remove(mbody);
					}
				}, 3000);
			} catch(e) {}
		};
		var _confunc = function() {
			if(_rowid == 0) {
				mail_move_callback();
				return false;
			}
			var params = {
				id: id,
				method: 1,
				dest: -1
			};
			mail_move(params, mail_move_callback, function() {
				_dialog.alert({info: '操作失败！'});
			});
		};
		_dialog.confirm({info: '您确定要放弃当前的这封草稿？', click: function() {
			_confunc();
		}});
	},
	
	// 在会话模式下读草稿
	readDraft: function(ret) {
		var o = {};
		ret.each(function(item) {
			if(item.folder == 2) {
				
			}
		});
	},
	
	// 创建单封信件显示的html
    createItemMail: function(mail, show, is_first_draft, is_last) {
		var _last_css = is_last ? ' last_item' : '';
		// 是否显示内容（如果是最后一封信件的话，一定默认展开内容）
		var is_show_c = is_last ? true : (!mail.display || mail.display == '' || mail.hidedisplay) ? false : (function() {
			mailRead.readMailCache['mail_' + mail.rowid] = mail;
			return true;
		})();
		if(is_first_draft) {
			var c = [];
			c.push('<div id="dialog_item_'+ mail.rowid +'" class="'+ (is_show_c ? 'dialog_item dialog_item_open' : 'dialog_item') +' corner-default">');
			
			c.push('<div class="dialog_item_lt"><div class="dialog_item_rt">');
			c.push('<div style="margin:0 auto 8px auto;width:auto;text-align:left;">');
			c.push('<b class="corner-xtop"><b class="corner-xb1"></b><b class="corner-xb2"></b><b class="corner-xb3"></b></b>');
			c.push('<div class="corner-shadow-xboxcontent">');
			c.push('<div class="corner-xboxcontent">');
			c.push('<div style="position:relative;width:100%;">');
			c.push('<div id="content_draft_info_'+ mail.rowid +'">');
			c.push((show && typeof show != 'boolean' ? show : ''));
			c.push('</div>');
			// c.push('<div style="width:100%;"><span style="font-size:0px;">&nbsp;</span></div>');
			c.push('</div>');
			c.push('</div>');
			c.push('</div>');
			c.push('<b class="corner-xbottom"><b class="corner-xb3"></b><b class="corner-xb2"></b><b class="corner-xb1"></b></b>');
			c.push('<div class="corner-shadow-xb4"></div>');
			c.push('</div>');
			c.push('</div></div>');
			
			c.push('</div>');
			return c.join('');
		}
        var mail_subj = (mail.envelope.subject.strip() == '') ? "无标题" : mail.envelope.subject;
        var _from = mail.envelope.from[0];
		if(!_from) _from = ['', '未知邮件地址'];
		_from = formatSysAccount(_from);
        var addrName = _from[1], myemail = UserSohuID, copyName = '', receiverName = '', recs = '', noInaddr = 0, receiverList = [];
        if (mail.envelope.to && mail.envelope.to.length > 0) {
            mail.envelope.to.each(function(s) {
                if (myemail != s[1] && s[1] != '') {
                    receiverName += s[1] + ',';
                }
				// 在 已发送 中，将收件人的拒收、添加到地址薄屏蔽
                recs += ("<span title='" + s[1] + "'>" + getSenderName(s) + "</span>, &nbsp;");
                //gaoyanxia 20081215
                if (s[1] != myemail) {
                    //gaoyanxia 20081210 如果有一个其他收件人不在地址薄中就显示添加联系人
                    if (!mailIsContact(s[1])) {
                        noInaddr++;
                    }
                    if (receiverList.length > 0) {
                        if (!mailIsReceive(s[1], receiverList)) {
                            receiverList.push(s);
                        }
                    } else {
                        receiverList.push(s);
                    }
                }
            });
        }
		
		var ccs = ""; //抄送
		if (mail.envelope.cc && mail.envelope.cc.length > 0) {
            mail.envelope.cc.each(function(s){
                if (myemail != s[1] && s[1] != '') {
                    copyName += s[1] + ',';
                }
				ccs += ("<span title='" + s[1] + "'>" +
                getSenderName(s) +
                "</span>, &nbsp;");
                //gaoyanxia 20081215
                if (s[1] != myemail) {
                    if (!mailIsContact(s[1])) {
                        noInaddr++;
                    }
                    if (receiverList.length > 0) {
                        if (!mailIsReceive(s[1], receiverList)) {
                            receiverList.push(s);
                        }
                    }
                    else {
                        receiverList.push(s);
                    }
                }
            });
        }
		
		readStarIcon = '<img class="am s_star '+ this.multiStar.star[mail.star] +'" star="'+ mail.star +'" sid="'+ mail.rowid +'" align="absmiddle" src="'+ MailConst.ALL +'/spacer.gif" title="'+ this.multiStar.title[mail.star] +'" style="cursor:pointer;display:inline;" />&nbsp; ';
		// readStarIcon = '<span class="am s_star '+ this.multiStar.star[mail.star] +'" star="'+ mail.star +'" sid="'+ mail.rowid +'" onclick="eventStop(event);mailConference._setStar(this, '+ mail.rowid +');" align="absmiddle" title="'+ this.multiStar.title[mail.star] +'" style="cursor:pointer;float:left;"></span>&nbsp; ';
		
        var pageContent = [];
		pageContent.push('<div style="text-align:center;" id="dialog_item_'+ mail.rowid +'" class="'+ (is_show_c ? 'dialog_item dialog_item_open' : 'dialog_item') + (mail.have_read == 0 ? ' corner-focus' : ' corner-default') + '">');
		
		pageContent.push('<div class="dialog_item_lt"><div class="dialog_item_rt">');
		pageContent.push('<div style="margin:auto;width:auto;text-align:left;"><b class="corner-xtop"><b class="corner-xb1"></b><b class="corner-xb2"></b><b class="corner-xb3"></b></b>');
		pageContent.push('<div class="corner-shadow-xboxcontent">');
		pageContent.push('<div class="corner-xboxcontent">');
		
        if (show && typeof show == 'boolean') {
			pageContent.push('<div class="option_info" id="option_info_title_'+ mail.rowid +'" mid="'+ mail.rowid +'">');
		} else {
			pageContent.push('<div class="option_info s_show_item" mid="'+ mail.rowid +'" style="cursor:pointer;">');
		}
		pageContent.push('<dt style="background-color:white;">');
		
		/*
		var _rep = '<a href="'+ this.f +'" class="s_bar_reply" mid="'+ mail.rowid +'" style="margin:auto 4px;" hidefocus="true">回复</a><span style="margin:auto 4px;">|</span><a href="'+ this.f +'" class="s_bar_replyall" mid="'+ mail.rowid +'" style="margin:auto 4px;" hidefocus="true">回复全部</a>';
		pageContent.push('<span class="option"><span id="option_info_'+ mail.rowid +'" style="display:'+ (is_show_c ? '' : 'none') +';padding:3px 15px 5px;_padding:0 15px;margin-right:2px;background:url('+ MailConst.ALL +'/operate_banner.gif) no-repeat;"><a href="'+ this.f +'" class="s_bar_show_info" mid="'+ mail.rowid +'" style="margin:auto 4px;" hidefocus="true">显示详细</a><span style="margin:auto 4px;">|</span>'+ _rep +'<span style="margin:auto 4px;">|</span><a href="'+ this.f +'" class="s_bar_forward" mid="'+ mail.rowid +'" style="margin:auto 4px;" hidefocus="true">转发</a><span style="margin:auto 4px;">|</span><img class="s_bar_menu" mid="'+ mail.rowid +'" left_dir="true" style="padding-right:12px;margin-right:-12px;_padding-right:9px;_margin-right:-9px;" align="absmiddle" style="cursor:pointer;" src="'+ MailConst.ALL +'/icon_line.gif" />');
		pageContent.push('</span>');
		if(mail.envelope.have_att) pageContent.push('<img align="absmiddle" src="'+ MailConst.ALL +'/icon_fujian1.gif"/>');
		pageContent.push(mail.envelope.display_date[0] +' ('+ mail.envelope.display_date[1] +'前)</span>');
		*/
        
		// var __ow = is_show_c ? '60%' : '85%';
		var __ow = is_show_c ? 'title_info title_info_hide' : 'title_info';
		pageContent.push('<div class="'+ __ow +'">');
		pageContent.push(readStarIcon + '&nbsp;');
		// var _name_class = (senderName.include(myemail)) ? 'orange' : 'blue';
		var _name_class = 'blue', senderName = '', senderMail = '';
		if(_from[1].include(myemail)) {
			_name_class = 'orange';
			senderName = '我';
		} else {
			senderName = _from[0] != '' ? _from[0] : _from[1].split('@')[0];
		}
		senderMail = _from[1];
		
		// senderName, mail.content.escapeHTML(), senderMail, mail.envelope.subject, ccs, (show && typeof show != 'boolean' ? show : '')
		var s_c = [senderName, mail.content.escapeHTML(), senderMail, mail.envelope.subject.stripTags()];
		try {
			if(mailSearch && this.searchApply && !is_last) {
				s_c = mailSearch.replaceHeighLight(s_c, mailSearch.searchWords);
			}
		} catch(e) {}
        pageContent.push('<b title="' + senderName + '" class="' + _name_class + '">' + (mail.folder != this.folder ? '['+ this._F[mail.folder] +']　' : '') + s_c[0] + '</b>');
		
		pageContent.push('<span style="margin:auto 16px auto 10px;">'+ mail.envelope.display_date[0] +'</span>');
		
		pageContent.push('<span id="op_info_'+ mail.rowid +'" mid="'+ mail.rowid +'" class="s_show_info cur-pt" style="display:'+ (!is_show_c ? 'none' : '') +';">'
			// +'<img class="arrow arrow-bottom" src="'+ MailConst.ALL +'/spacer.gif" />'
			+(!is_show_c || is_last ? '显示详细' : '隐藏详细')
			+'</span>');
		pageContent.push('<span id="title_info_'+ mail.rowid +'" style="color:#A4A4A4;white-space:nowrap;overflow:hidden;display:'+ (is_show_c ? 'none' : '') +';">' + s_c[1] + '</span>');
        pageContent.push('</div>');
		pageContent.push('</dt>');
		pageContent.push('</div>');
		pageContent.push('<div id="mail_info_'+ mail.rowid +'" '+ (is_last ? 'expand="true"' : '') +' style="width:100%;position:relative;display:'+ (is_show_c ? '' : 'none') +';">');
		
		
		pageContent.push('<div id="head_info_'+ mail.rowid +'" style="display:none;overflow:hidden;white-space:nowrap;">');
		
		
		pageContent.push('<div class="headinfo-area">');
        pageContent.push('<div class="headinfo">发件人：<font style="size:12px" title="' + addrName + '">' + s_c[2] + '</font>');
        if (this.folder != 3) {
            // 发件人是否在地址薄里面
            if (!mailIsContact(addrName)) {
                pageContent.push('<a id="rd_add_contact_'+ mail.rowid +'" class="s_save_addr" mid="'+ mail.rowid +'" href="'+ this.f +'" style="margin-left:15px;" hidefocus="true">保存到地址簿</a>');
            }
            // 发件人信箱是否被拒
            if (!mailIsBlack(addrName)) {
                pageContent.push('<a id="refuse.current.sender" class="s_addr_refuse" mid="'+ mail.rowid +'" href="'+ this.f +'" style="margin-left:15px;" hidefocus="true">拒收</a>');
            }
        }
		
        pageContent.push('</div>');
        // 是否显示回执提醒 1 是，0 不是
        var is_disp_notifier = 0;
        // 是否已经回复过了?? 1是 0 不是
        var is_disp_notifier_s = 0;
        if (recs != '') {
			 var is_single = 0;
			mail.envelope.userhdrs.each(function(v){
        		try{
        			if(v[0] == "X-Sohu-SingleSent" && v[1] == "1"){
            			is_single = 1;
            		}
                    if(v[0] == "Disposition-Notification-To"){
                        is_disp_notifier = 1;
                    }
                    if(v[0] == "Disposition-Notification-Sent"){
                        is_disp_notifier_s = 1;
                    }
        		} catch(e){}
       		});
            pageContent.push('<div class="headinfo">');
			if (is_single == 0) {
				pageContent.push('收件人：<font style="size:12px">' + recs + '</font>');
			} else {
				pageContent.push('分送给：<font style="size:12px">' + recs + '</font>');
			}
            if (noInaddr > 0) {
                pageContent.push('<a id="rd_add_contact_multi_'+ mail.rowid +'" class="s_save_all_addr" mid="'+ mail.rowid +'" href="'+ this.f +'" style="margin-left:15px;" hidefocus="true">保存所有收件人</a>');
            }
            pageContent.push('</div>');
        }
		pageContent.push('<div class="headinfo">主　题：<font style="size:12px">'+ s_c[3] +'</font></div>');
        pageContent.push('<div class="headinfo">时　间：<font style="size:12px">');
        // pageContent.push(mail.envelope.display_date[0] + '</font></div>');
		pageContent.push(strfTime(mail.envelope.date_sent*1000) + '</font></div>');
        if (ccs != '') {
            pageContent.push('<div class="headinfo">抄　送：<font style="size:12px">' + ccs);
            pageContent.push('</font></div>');
        }
		
		var atts = [];
		// var mat = this.folder == 2 ? mail.envelope.attach : mail.attach;
		var mat = mail.attach;
        try {
            if (mat && mat.length > 0) {
				var no_inline_attc = [], q = [];
				mat.each(function(_it) {
					if (_it[3] && _it[3] == 1) {
						if(!q || q.length == 0) q = _it;
						no_inline_attc.push(_it);
					}
				});
                if (q && q.length > 0) {
					var attrfiles = [];
					var singleimage = [];
					attrfiles.push('附件:&#10;');
					no_inline_attc.each(function(s){
						attrfiles.push(["● ", s[0], "(", s[2], ") &#10;"].join(''));
					});
					singleimage.push(["&nbsp;<img src='", MailConst.ALL, "/icon_fujian1.gif' align='absmiddle'/><a href='"+ this.f +"' class='s_filepreview' rid='"+ mail.rowid +"'", " hidefocus='true'>", q[0]].join(''));
					if (no_inline_attc.length > 1) {
						singleimage.push("&nbsp;&nbsp;...");
					}
					singleimage.push(["</a>(", q[2], ");（共", no_inline_attc.length, "个）"].join(''));
					pageContent.push('<div class="headinfo">附　件：');
					pageContent.push('<span title= "');
					pageContent.push(attrfiles.join(''));
					pageContent.push('">');
					pageContent.push(singleimage.join(''));
					pageContent.push('</span>');
					pageContent.push('</div>');
				}
				if (no_inline_attc && no_inline_attc.length > 0) {
					atts.push('<div>');
					atts.push('<div style="background-color:#FDFBF5;width:100%;">');
					atts.push('<span style="float:right;">关闭 ');
					atts.push('<img class="s_isclosefile" style="cursor:pointer;" src="');
					atts.push(MailConst.ALL);
					atts.push('/icon_bottom1.gif" align="absmiddle" />');
					atts.push('</span>');
                    if(no_inline_attc.length > 1){
                        atts.push('<span style="margin-left:10px;">附件预览&nbsp;&nbsp;&nbsp;&nbsp;共 ' + no_inline_attc.length + ' 个附件，<a href="download/' + mail.mid + '.4" target="_blank">全部下载</a></span>');
                        if(G.hasUDiskRights()){
                            atts.push(" <a href='javascript:;' onclick='mailAttchement.saveToUDisk(\""+mail.mid+"\");return false;'>转存到U盘</a>");
                        }
                        atts.push("</div>");
                    } else {
						atts.push('<span style="margin-left:10px;">附件预览</span></div>');
                    }
					atts.push('<div class="preview" id="read_att_pre_'+ mail.rowid +'">');
					atts.push(this.showAttcInfo(no_inline_attc));
					atts.push('</div>');
					atts.push('</div>');
				}
            }
        } catch (e) { }
        pageContent.push('</div></div>');
		
		
		pageContent.push('<div class="operate_area">'
			// +'<a href="main" id="op_info_'+ mail.rowid +'" class="s_bar_showinfo" mid="'+ mail.rowid +'">显示详细</a>'
			// +'<span class="v-line">|</span>'
			+'<div class="f-lf">'
			+'<a href="main" class="s_bar_reply" mid="'+ mail.rowid +'">回复</a>'
			+'<span class="v-line">|</span>'
			+'<a href="main" class="s_bar_replyall" mid="'+ mail.rowid +'">回复全部</a>'
			+'<span class="v-line">|</span>'
			+'<a href="main" class="s_bar_forward" mid="'+ mail.rowid +'">转发</a>'
			+'<span class="v-line">|</span>'
			+'<a href="main" class="s_bar_del" mid="'+ mail.rowid +'">删除</a>'
			+'<span class="v-line">|</span>'
			+'<a href="main" class="s_bar_delete" mid="'+ mail.rowid +'">彻底删除</a>'
			+'</div>'
			
			+'<div isshow="false" class="s_operate_all_v f-lf" style="display:none;white-space:nowrap;overflow:hidden;">'
			+'<span class="v-line">|</span>'
			+'<a href="./download/'+ mail.mid +'.0" target="_blank">源文件</a>'
			+'<span class="v-line">|</span>'
			+'<a href="./download/'+ mail.mid +'.1" target="_blank">下载邮件</a>'
			+'<span class="v-line">|</span>'
			+'<a href="" class="s_bar_print" mid="'+ mail.rowid +'">打印</a>'
			+'</div>'
			+'<span class="s_operate_all" style="margin-left:6px;margin-top:4px;cursor:pointer;float:left;"><img class="a-bg arrow arrow-right" src="'+ MailConst.ALL +'/spacer.gif" /></span></div>');
		
		
        // alva

        if(is_disp_notifier == 1 && is_disp_notifier_s == 0){
            pageContent.push('<div id="disposation_' + mail.rowid + '">');
            pageContent.push('<div id="disposition" style="height:25px;background-color:#ffe3b2;border:1px;border-color:#ffb15c;border-style:solid;padding-left:5px;font-size:14px;font-weight:bold;valign:absolute;line-height:25px;font-color:#d15300">');
            pageContent.push('<div id="disposition_desc" style="float:left">' + s_c[0] + '：希望得到您阅读此信的回执,是否发送?</div>');
            pageContent.push('<div id="disposition_controller" style="float:right; padding-right:10px;">');
            pageContent.push('<div style="float:left;margin-left:10px;text-decoration:underline;cursor:pointer" class="reply_notifier" mid="' + mail.rowid + '">发送</div>');
            pageContent.push('<div style="float:left;margin-left:10px;text-decoration:underline;cursor:pointer" class="cancel_reply_notifier" mid="' + mail.rowid + '">不发送</div>');
            pageContent.push('</div>');
            pageContent.push('</div>');
            pageContent.push('</div>');
        }

        //alva end
        pageContent.push('<ul id="content_info_'+ mail.rowid +'" class="ulstyle '+ _last_css +'">');
        pageContent.push('</ul>');
		pageContent.push('<div style="clear:both;font-size:1px;height:1px;">&nbsp;</div>');
		
		pageContent.push(atts.join(''));
		pageContent.push('<div id="content_draft_info_'+ mail.rowid +'">');
		pageContent.push((show && typeof show != 'boolean' ? show : ''));
		pageContent.push('</div>');
		
		if (is_last) {
			var _s = mail.envelope.from, _f = [];
			_s.each(function(item) {
				_f.push(item[1]);
			});
			var _from_all_c = format_mail(format_reply_to(mail).concat(format_filter(mail.envelope.to)));
			_from_all_c = format_filter_same(_from_all_c);
			var _op = '<div class="reply-operate" style="height:24px;"><div class="reply-operate-item reply-item-focus read-reply-1 s_reply" rid="'+ mail.rowid +'"><div class="am icon_reply icon-item read-icon-item"></div><div class="text-item read-text-item"> 回　复 </div></div><div class="reply-operate-item s_forward read-reply-2" rid="'+ mail.rowid +'"><div class="am icon_forward icon-item read-icon-item"></div><div class="text-item read-text-item"> 转　发 </div></div></div>';
			pageContent.push('<div id="last_reply_textarea_id">'+ _op +'<div class="reply-area"><textarea class="last_reply_textarea reply-textarea">'+ (_f.length > 0 ? ('快速回复给：' + _from_all_c) : '') +'</textarea><div style="height:10px;clear:both;">&nbsp;</div></div></div>');
		}
		
		// pageContent.push('<div style="width:100%;"><span style="font-size:0px;">&nbsp;</span></div>');
        pageContent.push('</div>');
		
		pageContent.push('</div></div>');
		pageContent.push('<b class="corner-xbottom"><b class="corner-xb3"></b><b class="corner-xb2"></b><b class="corner-xb1"></b></b>');
		pageContent.push('<div class="corner-shadow-xb4"></div></div>');
		pageContent.push('</div></div>');
		
		pageContent.push('</div>');
        return pageContent.join('');
    },
	
	createItemDraft: function(mail, isoperate, isforward) {
		if(!this.currentDraft) this.currentDraft = [];
		this.currentDraft.push(mail);
		var data = {}, _to = [], _cc = [], _bcc = [];
		mail.envelope.to.each(function(item) {
			if (item[0] != '') {
				_to.push(item[1] != '' ? ('\"'+ item[0] +'\"<'+ item[1] +'>') : item[0]);
			} else {
				_to.push(item[1]);
			}
		});
		mail.envelope.cc.each(function(item) {
			if (item[0] != '') {
				_cc.push(item[1] != '' ? ('\"'+ item[0] +'\"<'+ item[1] +'>') : item[0]);
			} else {
				_cc.push(item[1]);
			}
		});
		mail.envelope.bcc.each(function(item) {
			if (item[0] != '') {
				_bcc.push(item[1] != '' ? ('\"'+ item[0] +'\"<'+ item[1] +'>') : item[0]);
			} else {
				_bcc.push(item[1]);
			}
		});
		data['rowid'] = mail.rowid;
		data['to'] = _to.length > 0 ? _to.join(', ') + ', ' : '';
		if(_cc.length > 0) {
			data['show_cc'] = 'block';
			data['cc'] = _cc.join(', ') + ', ';
		} else {
			data['show_cc'] = 'none';
			data['cc'] = '';
		}
		if(_bcc.length > 0) {
			data['show_bcc'] = 'block';
			data['bcc'] = _bcc.join(', ') + ', ';
		} else {
			data['show_bcc'] = 'none';
			data['bcc'] = '';
		}
		if(isoperate) {
			var _rowid = typeof isoperate == 'object' ? isoperate.rowid : mail.rowid;
			var _f = isforward ? 'reply-item-focus' : '';
			var _r = isforward ? '' : 'reply-item-focus';
			data['replyoperate'] = new Template(draftReplyOperate).evaluate({'rowid': _rowid, 'reply_focus': _r, 'forward_focus': _f});
		} else {
			data['replyoperate'] = '';
		}
		data['subject'] = mail.envelope.subject;
		try {
			mail_send_e.init(['compose.wto'],6,UID+genKeyCode());
		} catch(e) {}
		return new Template(draftInConfTemplate).evaluate(data);
	},
	
	// 添加联系人（公用MailRead类中的添加接口）
	saveAddr: function(el, event) {
		var data = null, id;
		id = el.mid ? el.mid : el.getAttribute('mid');
		this.currentConference.each(function(item) {
			if(item.rowid == id) data = item;
		});
		if(!data) {
			_dialog.alert({info: '系统似乎出错了，请稍后再试~'});
			return false;
		}
		mailRead.saveAddr(el, event, data);
	},
	
	// 拒收某一封邮件（会话模式下只是把被拒收的人添加到黑名单中，界面上不发生任何的变化）
	refuseAddr: function(el) {
		var data = null, id;
		id = el.mid ? el.mid : el.getAttribute('mid');
		this.currentConference.each(function(item) {
			if(item.rowid == id) data = item;
		});
		if(!data) {
			_dialog.alert({info: '系统似乎出错了，请稍后再试~'});
			return false;
		}
		var _el = el;
		var confunc_refuse = function() {
			var params = {
				id: data.rowid,
				src : mailList.currentFolder,
				dest : -1,
				method: 1
			};
			var _e = data.envelope.from[0][1];
			mail_move(params, function(ret) {
				mailCfgClass.setMailCfgRefuse(_e, function() {
					_el.parentNode.removeChild(_el);
				});
			});
		};
		_dialog.confirm({info: '您确定要拒收吗？', click: function() {
			confunc_refuse();
		}});
	},
	
	// 添加多个收件人
	saveAllAddr: function(el, event) {
		var data = null, id;
		id = el.mid ? el.mid : el.getAttribute('mid');
		this.currentConference.each(function(item) {
			if(item.rowid == id) data = item;
		});
		if(!data) {
			_dialog.alert({info: '系统似乎出错了，请稍后再试~'});
			return false;
		}
		mailRead.saveAllAddr(el, event, data);
	},
	
	// 创建快捷回复的区域
	createFastReply: function(mail_item) {
		if(this.folder == 2 || this.folder == 3 || this.folder == 4) return '';
		var c = [], _f = [];
		var _s = mail_item.envelope.from.concat(mail_item.envelope.to);
		_s.each(function(item) {
			_f.push(item[1]);
		});
		var _sel = function() {
			var sc = [];
			replayOptions.each(function(item) {
				sc.push('<option value="'+ item +'">'+ item +'</option>');
			});
			return sc.join('');
		};
		
		this.fReply = _f.join(',');
		c.push('<div id="read_mail_replay" class="shortkey" style="background-color:#FDFBF5;width:auto;">');
        c.push('<div id="fastReplyDown" style="height:120px;display:'+ (replyState?'block':'none') +'">');
		c.push('<h5 id="replySuccMsg"  style="display:none;width: 520px;"><img src="'+ MailConst.ALL + '/icon_ok.gif" align="absmiddle" />您已成功回复本邮件！</h5>');
		c.push('<div style="margin-bottom: 10px;"><select id="selectReplay" onchange="mailConference.addValue();">')
		c.push(_sel());
		c.push('</select>');
		c.push('<span style="margin-top:-20px;">关闭 <img src="'+MailConst.ALL+'/icon_bottom1.gif" align="absmiddle"  onclick="mailConference.fastIsShow();" /></span></div>');
        c.push('<div><div style="float:left;"><textarea id="reply_textarea" style="height:80px;" cols="80" rows="4" class="grey" onblur="mailConference.resetValue();" onfocus="mailConference.changeValue();" onkeyup="javascript:return ctrlEnter(event);" >快速回复给：'+ this.fReply +'</textarea>');
        c.push('<input type="hidden" id="securityCode" /></div>');
        c.push('<div style="float:left;"><a id="reply_button"  class="square"  disabled="true" onclick="reply(currentMailItem,currentMailItem.folder);" href="'+ this.f +'" hidefocus="true"><img id="reply_img" src="'+ MailConst.ALL + '/button_revert_grey.jpg" /></a></div>');
		c.push('</div></div>');
		c.push('<div id="fastReplyUp" style="display:'+ (replyState?'none':'block') +'">');
		c.push('<span>打开 <img src="' + MailConst.ALL + '/icon_top1.gif" align="absmiddle"  onclick="mailConference.fastIsShow();"/></span>快速回复');
		c.push('<div class="shortcut"></div>');
		c.push('</div></div>');
		return c.join('');
	},
	
	fastIsShow: function() {
		var fd = $('fastReplyDown'), fu = $('fastReplyUp');
		if(Element.visible(fd)) {
			fd.hide();
			fu.show();
		} else {
			fd.show();
			fu.hide();
		}
	},
	
	// 点击附件定位到下载的位置
	focusPreview: function(id) {
		DOM.sohuMailMain.scrollTop = Position.cumulativeOffset($('read_att_pre_' + id))[1];
	},
	
	resetValue: function() {
		var rpltxt = $('reply_textarea');
		if (rpltxt.value == "") {
			rpltxt.value = "快速回复给：" + this.fReply;
			rpltxt.className = "grey";
			$('reply_img').src= MailConst.ALL +"/button_revert_grey.jpg";
		}
	},
	
	changeValue: function() {
		var rpltxt = $('reply_textarea');
    	if(rpltxt.value.startsWith("快速回复给：")){
			rpltxt.value = "";
			rpltxt.className = "black";
		}
		$('reply_img').src = MailConst.ALL + "/button_revert.jpg";
	},
	
	addValue: function() {
		var rpltxt = $('reply_textarea');
		replayIndex = $('selectReplay').selectedIndex;
    	if(replayIndex != 0){
    		rpltxt.value = $('selectReplay').options[replayIndex].value;
			rpltxt.className = "black";
    	}
		$('reply_img').src = MailConst.ALL +"/button_revert.jpg";
	},
	
	// 显示附件详细信息
	showAttcInfo: function(attach) {
		if(typeof attach != 'object' || attach.length == 0) return '';
    	var c = [];
		c.push('<table cellspacing=0 cellpadding=0 border=0 style="margin:10px;"><tbody>');
    	attach.each(function(item) {
			var att_name = item[0];
			if(mailSearch && this.searchApply) {
				att_name = mailSearch.replaceHeighLight([att_name], mailSearch.searchWords)[0];
			}
			c.push('<tr class="s_attach_item_area">');
			var d_url = './download/' + item[4] + '.1';
            var html_saveToUdisk = "";
            if (G.hasUDiskRights()){
                html_saveToUdisk = '<a href="javascript:;" style="margin:0 5px;" onclick="mailAttchement.saveToUDisk(\''+item[4]+'\',false)">转存到U盘</a>';
            }
			var _img_type = ['bmp', 'jpg', 'jpeg', 'gif', 'png', 'ico'],
			v_type = function(str) {
				var f = false;
				_img_type.each(function(item) {
					if(str.include(item) && !f) f = true;
				});
				return f;
			}
			if(item[1].include('image') && v_type(item[1])) {
				var p_url = './download/' + item[4] + '.0';
				var p_url1 = './download/' + item[4] + '.2';
				c.push(['<td style="padding:10px;"><a href="', p_url, '" target="_blank" hidefocus="true"><img src="', p_url1, '" style="width:160px;border:1px solid #E6E5E5;" /></a></td>',
		                '<td style="padding:10px;" valign="top"><div><span>', att_name, '</span>(', item[2], ')</div><div><a style="margin:0 5px;" href="', d_url, '" hidefocus="true">下载</a>'+html_saveToUdisk+'</div></td>'].join(''));
			} else {
				var p_url2 = './download/' + item[4] + '.3';
				try {
					var type = this.isKnow(item[0]);
				} catch(e) {}
				if (item[1].include('msword') || item[1].include('ms-excel') || item[1].include('pdf')) {
					c.push(['<td style="padding:10px;"><a href="', p_url2, '" target="_blank" hidefocus="true"><img src="', MailConst.ALL, "/type/", type, '.gif" /></a></td>', '<td style="padding:10px;" valign="top"><div><span>', att_name, '</span>(', item[2], ')</div><div><a style="margin:0 5px;" href="', d_url, '" hidefocus="true">下载</a>'+html_saveToUdisk+'<a style="margin:0 5px;" target="_blank" href="', p_url2, '" hidefocus="true">在线预览</a></div></td>'].join(''));
				}
				else {
					c.push(['<td style="padding:10px;"><img src="', MailConst.ALL, "/type/", type, '.gif" /></td>', '<td style="padding:10px;" valign="top"><div><span>', att_name, '</span>(', item[2], ')</div><div><a style="margin:0 5px;" href="', d_url, '" hidefocus="true">下载</a>'+html_saveToUdisk+'</div></td>'].join(''));
				}
			}
			c.push('</tr>');
   		}.bind(this));
		c.push('</tbody></table>');
    	return c.join('');
	},
	isKnow: function(type) {
		var k_types = ['txt', 'eml', 'doc', 'avi', 'pdf', 'ppt', 'rar', 'swf', 'wav', 'wma', 'xls', 'xml', 'zip', 'fla', 'mp3'];
		var _r = 'none';
		k_types.each(function(item) {
			if(type.toLowerCase().endsWith(item)) _r = item;
		});
		return _r;
	},
    isShow: function(mid) {
        var _opa = $('op_info_' + mid),
			// _op = $('option_info_' + mid),
			_cf = $('title_info_' + mid),
			_mf = $('mail_info_' + mid),
			_di = $('dialog_item_' + mid),
			// _ow = _mf.previousSibling.firstChild.lastChild,
			_exp = _mf.expand ? _mf.expand : _mf.getAttribute('expand'),
			_is_show = Element.visible(_mf);
		if(_exp == 'true') return false;
		if(arguments[1]) _is_show = (arguments[1] == 'hide' ? true : false);
		this.setShowExpand(mid, !_is_show);
        if (_is_show) {
            _mf.hide();
            // _op.hide();
			_opa.hide();
			_cf.show();
			// _ow.style.width = '85%';
			try {
				Element.removeClassName(_di, 'dialog_item_open');
			} catch(e) {}
			try {
				this.isShowExpand();
			} catch(e) {}
        } else {
			var _sp = document.createElement('span');
			with(_sp.style) {
				fontSize    = '12px';
				color       = '#888888';
				marginLeft  = '10px';
			}
			_sp.innerHTML = '载入中......';
			_cf.hide();
			Element.insert(_cf, {after: _sp});
			var self = this;
			var _sh = function() {
				_mf.show();
           		// _op.show();
				_opa.show();
				_cf.hide();
				// _ow.style.width = '60%';
				// Element.hide(_sp);
				Element.remove(_sp);
				_sp = null;
				var _c = $('content_info_'+mid);
				if (_c.innerHTML.blank()) {
					var current_item = mailRead.readMailCache['mail_' + mid];
					var new_c = current_item.display;
					try {
						if (self.searchApply) {
							var new_c = mailSearch.replaceHeighLight([new_c], mailSearch.searchWords);
						}
					} catch(e) {}
					if(current_item.maximum && current_item.maximum != '') {
						new_c = '<iframe id="maximum_'+ current_item.rowid +'" onload="resizeMailContent(\'maximum_'+ current_item.rowid +'\');" src="./download/'+ current_item.maximum +'.7" style="width:100%;height:800px;border:0px" frameborder=0></iframe>';
					}
					_c.innerHTML = new_c;
				}
				/*
				try {
					var _quote_list = $A(_c.getElementsByClassName('sohu_quote'));
					_quote_list.each(function(item) {
						if(item.innerHTML.stripTags().blank()) return false;
						self.isShowQuote(item);
						Element.hide(item);
					}.bind(self));
				} catch(e) {}
				*/
				try {
					Element.addClassName(_di, 'dialog_item_open');
				} catch(e) {}
				try {
					// _op = _cf = _mf = _di = _ow = _c = null;
				} catch(e) {}
				try {
					self.isShowExpand();
				} catch(e) {}
			};
			if(!mailRead.readMailCache['mail_' + mid]) {
				mail_read({id: mid}, function(ret) {
					mailRead.readMailCache['mail_' + mid] = ret;
					this.currentConference.each(function(item) {
						if(item.rowid == mid) item.display = ret.display;
					});
					_sh();
				}.bind(this), function() {
					_sp.innerHTML = '载入出错，请重试';
				});
			} else {
				_sh();
			}
        }
    },
    isHeadInfoShow: function(mid, el) {
		if (el) {
			// eventStop(event);
			// var EL = event.target;
			// el = $(el.firstChild);
			el = $(el);
		} else {
			// el = $($('op_info_' + mid).firstChild);
			el = $('op_info_' + mid);
		}
		var _el = $('head_info_' + mid);
        if (_el.visible()) {
            el.innerHTML = '显示详细';
			// el.removeClassName('arrow-top');
			// el.addClassName('arrow-bottom');
            _el.hide();
        } else {
            el.innerHTML = '隐藏详细';
			// el.removeClassName('arrow-bottom');
			// el.addClassName('arrow-top');
            _el.show();
        }
    }, 
	_getMailItem: function(id) {
		var _item = {};
		this.currentConference.each(function(item) {
			if(item.rowid == id) _item = item;
		});
		return _item;
	},
	
	// 获得某个folder的属性信息
	getFolderItem: function(id) {
		var _item = {};
		var _unread = 0;
		var _thread_unread = 0;
		if(typeof this.F != 'object') this.F = FOLDER.evalJSON();
		this.F.folders.each(function(item) {
			if(item.folder_id == id) _item = item;
			if(item.folder_id == 2 || item.folder_id == 3) return false;
			_unread += item.unread;
			_thread_unread += item.thread_unread;
		});
		/*
		if(id == -2) {
			return {
				unread: _unread,
            	name: '未读邮件',
            	thread_total: _thread_unread,
            	thread_unread: _thread_unread,
            	folder_id: -2,
            	total: _unread,
            	size: 0
			};
		}
		*/
		return _item;
	},
	// 读邮件刷新列表缓存
	setRead: function(id_list) {
		if(!id_list || id_list.length == 0) return false;
		var u = 0, rids = [];
		// 得到当前会话中的未读邮件，都分别在哪个文件夹中
		this.currentConference.each(function(item) {
			if(!item.have_read && !rids.include(item.folder)) rids.push(item.folder);
		});
		if(rids.length == 0) return false;
		var _send = function() {
			if(rids.length > 0) {
				var p = {
					id: id_list,
					method: 0
				};
				mail_move(p);
			}
		};
		var _i_read = false;
		this.F.folders.each(function(item) {
			rids.each(function(_item) {
				if(item.folder_id == _item) {
					item.thread_unread--;
					try {
						$('spnewmail_' + _item).innerHTML = item.thread_unread > 0 ? '(' + item.thread_unread + ')' : '';
					} catch(e) {}
				}
			});
			if(item.folder_id == -2 && !_i_read) {
				item.thread_unread--;
				try {
					$('spnewmail_-2').innerHTML = item.thread_unread > 0 ? '(' + item.thread_unread + ')' : '';
				} catch(e) {}
				_i_read = true;
			}
		}.bind(this));
		_send();
	},
	
	// 刷新左侧列表会话的最新数目
	setConferenceNew: function(f) {
		var t_unread = 0;
		f.each(function(item) {
			var d = $('spnewmail_' + item.folder_id);
			if(d) {
				if(item.thread_unread > 0) {
					d.innerHTML = '('+ item.thread_unread +')';
					// t_unread += item.thread_unread;
				} else {
					d.innerHTML = '';
				}
			}
		});
		/*
		if(t_unread > 0) {
			$('spnewmail_-2').innerHTML = '('+ t_unread +')';
		} else {
			$('spnewmail_-2').innerHTML = '';
		}
		*/
	},
	
	// 设置某一封会话是否被选中
	setConfSel: function(obj) {
		if(obj.checked) {
			// obj.parentNode.parentNode.style.backgroundColor = '#FFCB7B';
			$(obj.parentNode.parentNode).addClassName('item_focus');
		} else {
			// obj.parentNode.parentNode.style.backgroundColor = '';
			$(obj.parentNode.parentNode).removeClassName('item_focus');
			try {
				$('conference_all').checked = false;
			} catch(e) {}
		}
	},
	
	// 设置所有列表是否被选中
	setConfAllSel: function(obj) {
		var ls = $A($('inbox').getElementsByTagName('input'));
		if(obj.checked) {
			ls.each(function(item) {
				if(item.className.include('conference_item')) {
					item.checked = true;
					// item.parentNode.parentNode.style.backgroundColor = '#FFCB7B';
					$(item.parentNode.parentNode).addClassName('item_focus');
				}
			});
		} else {
			ls.each(function(item) {
				if(item.className.include('conference_item')) {
					item.checked = false;
					// item.parentNode.parentNode.style.backgroundColor = '';
					$(item.parentNode.parentNode).removeClassName('item_focus');
				}
			});
		}
	},
	
	// 回复
	replyMail: function(id, type, is_cf) {
		var _type = ['reply', 'replyall', 'forward'];
		var _mail = typeof id == 'object' ? id : this._getMailItem(id);
		var _draft = $('content_draft_info_' + _mail.rowid);
		if(_mail.rowid == this._last_id) {
			var _rpt = $('last_reply_textarea_id');
			try {
				if(_rpt) _rpt.parentNode.removeChild(_rpt);
			} catch(e) { }
		}
		if (_draft) {
			var _draft_cont = $('draft_' + _mail.rowid);
			// if(!_draft_cont) {
				var _f = type == 'forward' ? true : false;
				_draft.innerHTML = this.createItemDraft(_mail, true, _f);
				this.createItemDraftEditor([_mail], true, _f);
			// } else {
			// 	_draft_cont.show();
			// }
			var self = this;
			var _t = setTimeout(function() {
				clearTimeout(_t);
				_t = null;
				self.setReplyContent(_mail, type);
				var _draft_y = Position.cumulativeOffset(_draft)[1];
				DOM.sohuMailMain.scrollTop = _draft_y + $('draft_' + _mail.rowid).getHeight() - document.body.clientHeight + 36;
			}, 100);
		}
		return false;
	},
	// 控制会话中的写信界面的内容动态更改
	setReplyContent: function(_mail, _type) {
		var __to = $('to_' + _mail.rowid), __cc_el = $('cc_' + _mail.rowid), __cc = $('wcc_' + _mail.rowid), __bcc_el = $('bcc_' + _mail.rowid), __bcc = $('wbcc_' + _mail.rowid), __subject = $('subject_' + _mail.rowid), __o = this._editor['e_' + _mail.rowid];
		var _from_c = format_mail(format_reply_to(_mail)), _from_all_c = format_mail(format_reply_to(_mail).concat(format_filter(_mail.envelope.to))), _cc_c = format_mail(format_filter(_mail.envelope.cc)), _bcc_c = format_mail(format_filter(_mail.envelope.bcc)), _sub = _mail.envelope.subject;
		var _replytoken = mailCfgClass.getProfileContent().replytoken ? mailCfgClass.getProfileContent().replytoken : '回复:';
		var _s = _type == 'forward' ? (_sub.startsWith('转发') ? _sub : '转发：' + _sub) : ((_sub.startsWith('回复') || _sub.startsWith('答复') || _sub.startsWith('Re')) ? _sub : _replytoken + _sub);
		try {
			if(_type == 'reply' || _type == 'replyall') {
				_mail.envelope.draft_type = 2;
			} else if(_type == 'forward') {
				_mail.envelope.draft_type = 1;
			}
		} catch(e) {}
		var fwdata = function(_mail, _content) {
			var data = {};
			var _dp = _mail.display ? _mail.display : '';
			var _from = _mail.envelope.from[0] ? _mail.envelope.from[0] : ['', ''];
			data['email'] = _from[1];
			data['name'] = getSenderName(_from);
			data['subject'] = _mail.envelope.subject;
			data['date'] = strfTime(_mail.envelope.date_sent*1000);
			var ccs = '';
			_mail.envelope.cc.each(function(_item) {
				ccs += ("<span title='" + _item[1] + "'>" +
                getSenderName(_item) +
                "</span>, &nbsp;");
			});
			data['cc'] = ccs != '' ? '<b>抄　送:</b> '+ ccs +'<br />' : '';
			data['content'] = _content ? _dp + _content : _dp;
			var c = new Template(revertMailTemplate).evaluate(data);
			return "<br /><br /><br /><div id='addMailSign'><span> </span></div><div id='mailcontent'>"
				+ c.replace(/id=\"sohu_mail_stationery_name\"/g, "").replace(/id=\"sohu_mail_stationery_content\"/g,"").replace(/id=\"addMailSign\"/g,"").replace(/id=\"imageSign\"/g,"").replace(/id=\"personalSign\"/g,"").replace(/id=\"textSign\"/g,"")+"</div>";
		};
		var _content = _type == 'forward' ? ('<br /><br /><br />' + (_mail.display ? _mail.display : '')) : (mailCfgClass.getProfileContent().includeoriginal == 'manual' ? '' : fwdata(_mail));
		
		var _p = mailCfgClass.getProfileContent(), _pc = '';
		if((!_p.signature || _p.signature.stripTags() == '') && (!_p.image_signature || !_p.image_signature_name)) {
			_pc = '';
		} else {
			var _html = [];
			_html.push('<br /><br /><br /><br /><br /><br />');
			_html.push('<div><table cellspacing=0 cellpadding=0 style="border:0;margin:0px;padding:0px;"><tbody><tr style="vertical-align:top;"><td style="margin:0px 4px;">');
			_html.push((_p.image_signature && _p.image_signature_name && _p.image_signature_name.strip() != '') ? '<img src="' + SIGN_ROOT + '/' + _p.image_signature_name + '.jpg" style="border:0;" />' : '');
			_html.push('</td><td style="margin:0px 4px;">');
			_html.push(_p.signature ? _p.signature : '');
			_html.push('</td></tr></tbody></table></div>');
			_pc = _html.join('');
		}
		_content = _pc + _content;
		if(_type == 'reply') {
			__to.value = !_from_c.blank() ? _from_c + ', ' : '';
			__cc.value = '';
			__bcc.value = '';
			__cc_el.hide();
			__bcc_el.hide();
		} else if(_type == 'replyall') {
			__to.value = !_from_all_c.blank() ? _from_all_c + ', ' : '';
			if (!_cc_c.blank()) {
				__cc.value = _cc_c + ', ';
				__cc_el.show();
			} else {
				__cc_el.hide();
			}
			if(!_bcc_c.blank()) {
				__bcc.value = _bcc_c + ', ';
				__bcc_el.show();
			} else {
				__bcc_el.hide();
			}
		} else if(_type == 'forward') {
			__to.value = '';
			__cc.value = '';
			__bcc.value = '';
			__cc_el.hide();
			__bcc_el.hide();
		}
		__subject.value = _s;
		var __i = 0;
		var self = this;
		var _set_content = function() {
			var _sf = arguments.callee;
			__o = self._editor['e_' + _mail.rowid];
			try {
				var _j = __o && __o.c() && __o.c().document.body && typeof __o.c().document.body.innerHTML == 'string';
			} catch(e) {}
			if(_j) {
				var __t = setTimeout(function() {
					clearTimeout(__t);
					__t = null;
					__o.setContent(_content);
					__o.setSelect(__o.c().document.body, 0, 0);
					__o.focus();
					__o.origin_content = __o.getContent();
					
					try {
						$A($(__o.c().document.body).getElementsByClassName('s_show_blockquote')).each(function(item) {
							var e = item.nextSibling, en = null;
							while(e) {
								if(e.nodeType == 1 && Element.hasClassName(e, 'sohu_quote')) {
									en = e;
									break;
								}
								e = e.nextSibling;
							}
							Element.show(en);
							item.parentNode.removeChild(item);
						});
					} catch(e) {
					}
				}, 100);
			} else {
				if(__i > 10) return false;
				var _t = setTimeout(function() {
					clearTimeout(_t);
					_t = null;
					__i ++ ;
					_sf();
				}, 100);
			}
		};
		_set_content();
	},
	
	// 在会话界面，删除会话中的信件，或者删除整个会话
	delMail: function(id_list, type, conf) {
		if(id_list.length == 0) return;
		if(type == 'delete' && !conf) {
			var _SF = arguments.callee, self = this, _id_list = id_list;
			_dialog.confirm({info: '您真的确定要删除会话？', click: function() {
				_SF.apply(self, [_id_list, 'delete', true]);
				_SF = null;
			}});
			return false;
		}
		
		if(type == 'spam' && !conf) {
			// _dialog.custom();
			var _senders = [];
			this.currentConference.each(function(item) {
				var s = [].concat(item.envelope.from_after_1st_unread).concat(item.envelope.from);
				s.each(function(__im) {
					if(!_senders.include(__im[1])) _senders.push(__im[1]);
				});
			});
			var _SF = arguments.callee, self = this;
			if(!this.spamMailLayer(_senders, false, function() {
				_SF.apply(self, [id_list, 'spam', true, function(ret) {
					var _cid = $('content_id');
					if(_cid) {
						_cid.innerHTML = '<dt class="t-txt">举报成功！邮件已提交反垃圾系统数据中心！</dt><div><div> 今天搜狐反垃圾系统共收到<b> '+ ret.spamall +' </b>次举报 </div><div> 共拦截了<b> '+ ret.spammail +' </b>封垃圾邮件 </div><div> 感谢您对搜狐邮箱反垃圾工作的支持！ </div></div><div style="margin-top:20px;text-align:center;"><input class="button6" type="button" value="　关闭窗口　" onclick="_dialog.closeCustom();" /></div>';
					}
				}]);
			})) return false;
			return false;
		}
		
		
		var _d = 0, _m = 1, _tips = '';
		switch(type) {
			case 'del':
				_d = 4;
				_tips = this.op_tips['fid_4'];
				break;
			case 'delete':
				_d = -1;
				_tips = this.op_tips['fid_-1'];
				break;
			case 'spam':
				_d = -1;
				_m = 3;
				_tips = this.op_tips['fid_3'];
				break;
			case 'unspam':
				_d = 1;
				_m = 1;
				_tips = this.op_tips['fid_1'];
				break;
			default:
				_tips = this.op_tips['fid_0'];
				break;
		}
		if(typeof type == 'number') {
			_d = type;
		}
		if (type == 'undel') {
			var params = {
				id: id_list,
				method: 4
			};
		} else {
			var params = {
				id: id_list,
				method: _m,
				// src: this.folder,
				dest: _d
			};
		}
		var _cb = arguments[3];
		mail_move(params, function(ret) {
			if(_cb && typeof _cb == 'function') {
				_cb(ret);
			}
		});
		var _thread = this.currentConference[0].thread;
		try {
			// 清掉列表页面的缓存，还有和当前会话相关的缓存
			this.clearListCache();
			this.clearThreadCache(_thread, this.folder);
		} catch(e) {}
		if(id_list.length == 1 && this.currentConference.length > 1) {
			var e = $('dialog_item_' + id_list[0]);
			if(!e) return;
			// 操作缓存
			var i = 0;
			this.currentConference.each(function(item, index) {
				if (item.rowid == id_list[0]) {
					i = index;
				}
			});
			this.currentConference = this.currentConference.slice(0,i).concat(this.currentConference.slice(i+1));
			if(this.currentConference.length == 0) {
				if (this.folder != -2) {
					var _index = 0;
					this.cacheList.each(function(item, index){
						if (item.thread == _thread) _index = index;
					});
					this.cacheList = this.delCinList(_index, this.cacheList);
				}
				if (NEXT_ID) {
					this.getMailRead(NEXT_ID);
				} else if(PREV_ID) {
					this.getMailRead(PREV_ID);
				} else {
					changePanel('mailList', this.folder);
				}
				return;
			}
			var t = new Template(hintTemplate).evaluate({message: '该邮件已移至“已删除邮件”'});
			var d = document.createElement('div');
			d.style.width = '100%';
			d.style.marginTop = '10px';
			d.innerHTML = t;
			// e = e.parentNode;
			Element.insert(e, {'after': d});
			e.parentNode.removeChild(e);
			e = null;
			var _t = setTimeout(function() {
				clearTimeout(_t);
				_t = null;
				d.parentNode.removeChild(d);
				d = null;
			}, 3000);
		} else {
			if (this.folder != -2) {
				var _index = 0;
				this.cacheList.each(function(item, index){
					if (item.thread == _thread) _index = index;
				});
				// 如果是未读邮件，当前邮件已经在列表中被删除了
				this.cacheList = this.delCinList(_index, this.cacheList);
			}
			if (NEXT_ID) {
				this.getMailRead(NEXT_ID);
			} else if(PREV_ID) {
				this.getMailRead(PREV_ID);
			} else {
				changePanel('mailList', this.folder);
			}
			try {
				if(_tips) Tips.show(_tips, 5);
			} catch(e) {}
			return;
		}
	},
	getSelectMailList:function(){
		var t = $A($('inbox').getElementsByTagName('input'));
		var ret = {};
		var sel = [];
		t.each(function(item) {
			if(item.className.include('conference_item') && item.checked) {
				var e = item.parentNode.parentNode;
				var _id = e.id ? e.id : e.getAttribute('id');
				sel.push(_id);
			}
		});
		ret.selected = sel;
		return ret;
	},
	// 垃圾举报的提示层
	spamMailLayer: function(senders, sys, callfunc) {
		if(senders.length == 0 || sys) {
			_dialog.alert({info: '搜狐系统邮件不可举报并拒收！'});
			return false;
		}
		var _data = [];
		_data['is_sys_mail'] = sys ? '<div>（搜狐系统邮件将不会被举报并拒收！）</div>' : '';
		var _c = [],  _csid = [];
		senders.each(function(__im) {
			if(getSysAccount(__im) || mailIsWhite(__im) || mailIsContact(__im)) return false;
			_csid.push(__im);
			// _c.push('<div><span><input type="checkbox" checked value="" id="'+ __im +'" /></span><span><label for="'+ __im +'">'+ __im +'</label></span></div>');
		});
		_data['spam_sender'] = '<div style="margin:10px auto 16px;"><input id="spam_senders" type="checkbox" checked value="" /> 将发件人列入黑名单 </div>';
		_data['event_id'] = 'spam_current_mails';
		_data['content_id'] = 'contact_list_id';
		_data['did'] = 'drag_id';
		_data['cid'] = 'content_id';
		var _t = new Template(mailSpamLayerTemplate).evaluate(_data);
		_dialog.custom({
			html: _t,
			style: {width:'400px', height:'160px', backgroundColor:'white'},
			dragid: 'drag_id'
    	});
		var _eid = $('spam_current_mails');
		// 垃圾邮件的分类
		
		// var _cid = $('contact_list_id');
		
		if (_eid) {
			Event.observe(_eid, 'click', function(event){
				
				var _stype = $('spamtype_1').checked ? 'spam_ads' : $('spamtype_2').checked ? 'spam_unsubscribe' : $('spamtype_3').checked ? 'spam_cheat' : $('spamtype_4').checked ? 'spam_other' : '';
				/*
				$A(_cid.getElementsByTagName('input')).each(function(item) {
					if(item.checked && !item.disabled) _csid.push(item.id);
				});
				*/
				
				if(callfunc && typeof callfunc == 'function') {
					callfunc();
				}
				var _c = $('content_id'), _ss = $('spam_senders');
				var _ssm = _ss.checked ? true : false;
				if(_c) {
					_c.innerHTML = '<div style="padding-top:40px;text-align:center;"><img src="'+ MailConst.ALL +'/loading_2.gif" /><div style="padding-top:40px;"><input class="button6" type="button" value="　关闭窗口　" onclick="_dialog.closeCustom();" /></div></div>';
				}
				
				// _dialog.closeCustom();
				if(_stype && _stype != '') jsoplog.ucCapture(_stype);
				if (_csid.length > 0 && _ssm) {
					mod_blacklist({blocklist: _csid.join(',')}, function(ret){
						// mailAddressClass.initCache(true);
						if(ret.status == true) {
							if (Object.isArray(ret.msg)) {
								blackLists = blackLists.concat(ret.msg);
							} else {
								blackLists.push(ret.msg);
							}
						}
					});
				}
			});
		}
		return false;
	},
	// 在列表页面操作会话
	delMailInList: function(type, conf) {
		var sel = this.getSelectMailList().selected;
		if(sel.length == 0) {
			_dialog.alert({info: '请选择需要操作的会话'});
			return false;
		}
		
		// 如果是垃圾举报，那么就提示用户选择垃圾举报的分类
		if(type == 'spam' && !conf) {
			var _ids = [];
			sel.each(function(item) {
				_ids.push(item.split('_')[1]*1);
			});
			var _senders = [], _is_sys = false;
			this.cacheList.each(function(_item) {
				if(_ids.include(_item.thread)) {
					var _f = [].concat(_item.envelope.from).concat(_item.envelope.from_after_1st_unread);
					_f.each(function(_im) {
						var _s = getSysAccount(_im[1]);
						if(!_is_sys)_is_sys = _s;
						if(!_senders.include(_im[1]) && !_s && (UserSohuID != _im[1])) _senders.push(_im[1]);
					});
				}
			});
			
			var _SF = arguments.callee, self = this;
			if(!this.spamMailLayer(_senders, _is_sys, function() {
				_SF.apply(self, ['spam', true, function(ret) {
					var _cid = $('content_id');
					if(_cid) {
						_cid.innerHTML = '<dt class="t-txt">举报成功！邮件已提交反垃圾系统数据中心！</dt><div><div> 今天搜狐反垃圾系统共收到<b> '+ ret.spamall +' </b>次举报 </div><div> 共拦截了<b> '+ ret.spammail +' </b>封垃圾邮件 </div><div> 感谢您对搜狐邮箱反垃圾工作的支持！ </div></div><div style="margin-top:20px;text-align:center;"><input class="button6" type="button" value="　关闭窗口　" onclick="_dialog.closeCustom();" /></div>';
					}
				}]);
			})) return false;
		}
		
		if(type == 'delete' && !conf) {
			var _SF = arguments.callee, self = this;
			_dialog.confirm({info: '您真的确定要删除会话？', click: function() {
				_SF.apply(self, ['delete', true]);
				_SF = null;
			}});
			return false;
		}
		var ids = [], _unreads = [], zhiyou = [];
		sel.each(function(item) {
			if($(item)) $(item).remove();
			var __id = (function() {
				try {
					return item.split('_')[1];
				} catch(e) {
					return false;
				}
			})();
			this.cacheList.each(function(_item) {
				// if (item.include(_item.thread)) {
				if(__id == _item.thread) {
					ids = ids.concat(_item.rowids);
					if (_item.unread > 0) {
						_unreads.push(_item);
						try {
							var _addr = _item.envelope.from.length > 0 ? _item.envelope.from[0][1] : _item.envelope.from_after_1st_unread[0][1];
							if(getZhiYouAccount(_addr)) {
								zhiyou.push([_addr, '|0'].join(''));
							}
						} catch(e) {}
					}
				}
			});
		}.bind(this));
		var dest = 0, method = 1, _tips = '';
		if (typeof type == 'number') {
			dest = type;
			if (this.folder == -2) {
				_unreads.each(function(item) {
					this.F.folders.each(function(_item) {
						if(item.folder == _item.folder_id && item.folder != type) {
							_item.thread_unread --;
						} else if(_item.folder_id == type && item.folder != type) {
							_item.thread_unread ++;
						}
					});
				}.bind(this));
			} else {
				this.F.folders.each(function(item){
					if (item.folder_id == type) {
						item.thread_unread += _unreads.length;
					} else if (item.folder_id == this.folder) {
						item.thread_unread -= _unreads.length;
					}
				}.bind(this));
			}
			_tips = this.op_tips['fid_0'];
		} else {
			switch (type) {
				case 'del':
					dest = 4;
					method = 1;
					// messageInfo = '邮件已删除!';
					_tips = this.op_tips['fid_4'];
					break;
				case 'delete':
					dest = -1;
					method = 1;
					// messageInfo = '邮件已经永久删除!';
					_tips = this.op_tips['fid_-1'];
					break;
				case 'spam':
					dest = -1;
					method = 3;
					// messageInfo = '举报成功！邮件已清除！';
					// messageInfo = '';
					_tips = this.op_tips['fid_3'];
					break;
				case 'unspam':
					dest = 1;
					method = 1;
					_tips = this.op_tips['fid_1'];
					break;
				default:
					_tips = this.op_tips['fid_0'];
					break;
			};
			this.F.folders.each(function(item){
				if (item.folder_id == this.folder) {
					item.thread_unread -= _unreads.length;
				}
			}.bind(this));
		}
		// var self = this;
		if (type == 'undel') {
			var params = {
				id: ids,
				method: 4
			};
		} else {
			if (type == 'delete' || type == 'spam' || type == 'del') {
				var params = {
					id: ids,
					dest: dest,
					method: method,
					sys_mails: zhiyou.join()
				};
			} else {
				var params = {
					id: ids,
					dest: dest,
					method: method
				};
			}
		}
		var _cb = arguments[2];
		mail_move(params, function(ret) {
			this.getMailList(this.folder, this.page);
			if(_cb && typeof _cb == 'function') _cb(ret);
		}.bind(this));
		try {
			if(_tips) Tips.show(_tips, 5);
		} catch(e) {}
		try {
			// 清掉所有的列表页面缓存
			this.clearListCache();
		} catch(e) {}
	},
	
	sourceMail: function(mid) {
		window.open('download/' + mid + '.0');
	},
	
	downloadMail: function(mid) {
		window.open('download/' + mid + '.1');
	},
	
	// 信件打印
	printMail: function(id) {
		// var _domain = localDomain;
		var _domain = isDomain ? localDomain : undefined;
		var _d = _domain ? 'document.domain="'+ _domain +'";' : '';
		var _url = 'javascript:document.open();'+ _d +'document.write("<html><head><style></style></head><body></body></html>");document.close();';
		var o = window.open(_url, '', 'channelmode=yes,toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
		var _loaded_id = 'loaded_div';
		var _print = function() {
			var _sf = arguments.callee;
			var t = setTimeout(function() {
				clearTimeout(t);
				t = null;
				try {
					if (!o.document.getElementById(_loaded_id)) {
						_sf();
						return;
					}
					o.print();
				} catch(e) {}
			}, 10);
		};
		var it = $('mail_info_' + id);
		var cc = document.createElement('div');
		
		cc.appendChild(it.firstChild.cloneNode(true));
		// cc.appendChild(it.firstChild.nextSibling.cloneNode(true));
		$A(it.childNodes).each(function(item) {
			if(item.nodeName.toLowerCase() == 'ul') {
				cc.appendChild(item.cloneNode(true));
			}
		});
		
		// cc.appendChild(it.cloneNode(true));
		/*
		$A($(cc).getElementsByClassName('operate_area')).each(function(_item) {
			_item.parentNode.removeChild(_item);
			_item = null;
		});
		*/
		$A($(cc).getElementsByClassName('s_show_blockquote')).each(function(_item) {
			_item.parentNode.removeChild(_item);
			_item = null;
		});
		var _drf = $('dialog_read').firstChild;
		Element.setStyle(_drf.firstChild, {'float':'none'});
		var ch = _drf.cloneNode(false);
		ch.appendChild(_drf.firstChild.cloneNode(true));
		var ct = document.createElement('div');
		with(ct.style) {
			fontFamily   = 'Arial,Helvetica,sans-serif';
			fontSize     = '12px';
			lineHeight   = '1.6';
		};
		ct.appendChild(ch);
		ct.appendChild(cc);
		cc.firstChild.style.display = 'block';
		$A(cc.firstChild.getElementsByTagName('a')).each(function(item) {
			item.parentNode.removeChild(item);
			item = null;
		});
		with(ch.style) {
			borderBottom   = '1px solid #D7D7D7';
			marginBottom   = '10px';
			color          = '#000000';
			fontSize       = '14px';
			fontWeight     = 'bold';
			height         = 'auto';
			lineHeight     = '26px';
			width          = 'auto';
		};
		$A(cc.firstChild.childNodes).each(function(item) {
			with(item.style) {
				margin   = '0px 0px 3px 10px';
				padding  = '0px';
			};
		});
		var P = document.createElement('div');
		var _tmp = document.createElement('div');
		_tmp.id = _loaded_id;
		_tmp.setAttribute('id', _loaded_id);
		P.appendChild(ct);
		P.appendChild(_tmp);
		var clearDom = function() {
			if(it) it = null;
			if(cc) cc = null;
			if(ch) ch = null;
			if(ct) ct = null;
			if(P) P = null;
		};
		if(Prototype.Browser.Gecko) {
			o.onload = function() {
				o.document.body.innerHTML = P.innerHTML;
				clearDom();
				_print();
			};
		} else {
			var _t = setTimeout(function() {
				clearTimeout(_t);
				_t = null;
				o.document.body.innerHTML = P.innerHTML;
				clearDom();
				_print();
			}, 200);
		}
	},
	// 被调用的事件行为尽量函数化，可能在其他的类中调用到
	// 会话中的读信页面是否显示抄送、密送、主题等内容
	showDraftCC: function(event, EL) {
		var mid = Element.getParentNodeByAttribute(EL, 'mid');
		if(mid) var e = $('cc_' + mid.attribute);
		try {
			if (Element.visible(e)) {
				e.hide();
			} else {
				e.show();
			}
		} catch(e) {}
	},
	showDraftBCC: function(event, EL) {
		var mid = Element.getParentNodeByAttribute(EL, 'mid');
		if(mid) var e = $('bcc_' + mid.attribute);
		try {
			if (Element.visible(e)) {
				e.hide();
			} else {
				e.show();
			}
		} catch(e) {}
	},
	showDraftSub: function(event, EL) {
		var mid = Element.getParentNodeByAttribute(EL, 'mid');
		if(mid) var e = $('sub_' + mid.attribute);
		try {
			if (Element.visible(e)) {
				e.hide();
			} else {
				e.show();
			}
		} catch(e) {}
	},
	// 是否显示可预览的附件
	showAttachFile: function(event, EL) {
		var _p = EL.parentNode.parentNode.nextSibling;
		var _c = EL.parentNode;
		if(Element.visible(_p)) {
			Element.hide(_p);
			_c.innerHTML = '打开 <img class="s_isclosefile" style="cursor:pointer;" src="' + MailConst.ALL + '/icon_top1.gif" align="absmiddle" />';
		} else {
			Element.show(_p);
			_c.innerHTML = '关闭 <img class="s_isclosefile" style="cursor:pointer;" src="' + MailConst.ALL + '/icon_bottom1.gif" align="absmiddle" />';
		}
	},
	replyFunction: function(event, EL) {
		// var e = Element.getParentNodeByClassName(EL, 's_reply');
		var e = EL;
		try {
			if(!$(e).hasClassName('read-reply-1') && $(e).hasClassName('reply-item-focus')) return false;
		} catch(e) {}
		try {
			var rid = Element.getParentNodeByAttribute(e, 'rid');
			var _sf = arguments.callee, self = this;
			if(!arguments[2] && !this._editor_content_check('e_' + rid.attribute, function() {
				_sf.apply(self, [event, EL, true]);
			})) return false;
			this.replyMail(rid.attribute*1, 'reply');
		} catch(e) {}
		try {
			Element.addClassName(e, 'reply-item-focus');
			Element.removeClassName(e.nextSibling, 'reply-item-focus');
		} catch(e) {}
	},
	replyAllFunction: function(event, EL) {
		// var e = Element.getParentNodeByClassName(EL, 's_reply_all');
		var e = EL;
		try {
			var rid = Element.getParentNodeByAttribute(e, 's_reply_all');
			this.replyMail(rid.attribute*1, 'replyall');
		} catch(e) {}
		try {
			Element.addClassName(e, 'reply-item-focus');
			Element.removeClassName(e.nextSibling, 'reply-item-focus');
		} catch(e) {}
	},
	forwardFunction: function(event, EL) {
		// var e = Element.getParentNodeByClassName(EL, 's_forward');
		var e = EL;
		try {
			if(!$(e).hasClassName('read-reply-2') && $(e).hasClassName('reply-item-focus')) return false;
		} catch(e) {}
		try {
			var rid = Element.getParentNodeByAttribute(e, 'rid');
			var _sf = arguments.callee, self = this;
			if(!arguments[2] && !this._editor_content_check('e_' + rid.attribute, function() {
				_sf.apply(self, [event, EL, true]);
			})) return false;
			this.replyMail(rid.attribute*1, 'forward');
		} catch(e) {}
		try {
			Element.addClassName(e, 'reply-item-focus');
			Element.removeClassName(e.previousSibling, 'reply-item-focus');
		} catch(e) {}
	},
	// 展开会话中的所有信件
	expandAllFunction: function(event, EL) {
		var tid = Element.getParentNodeByAttribute(EL, 'tid');
		try {
			this.operateAllMails(tid.attribute, 'expand');
		} catch(e) {}
		try {
			if (EL.nextSibling.nodeName.toLowerCase() == 'span') {
				Element.hide(EL);
				Element.show(EL.nextSibling);
			}
		} catch(e) {}
	},
	// 收起会话中的所有信件
	shrinkAllFunction: function(event, EL) {
		var tid = Element.getParentNodeByAttribute(EL, 'tid');
		try {
			this.operateAllMails(tid.attribute, 'shrink');
		} catch(e) {}
		try {
			if (EL.previousSibling.nodeName.toLowerCase() == 'span') {
				Element.hide(EL);
				Element.show(EL.previousSibling);
			}
		} catch(e) {}
	},
	attachFilePreview: function(event, EL) {
		var rid = Element.getParentNodeByAttribute(EL, 'rid');
		try {
			if(rid) {
				this.focusPreview(rid.attribute);
			}
		} catch(e) {}
	},
	
	/* 
	// 会话列表的缓存数据
	this.conferenceListCache = {};
	// 会话内容的缓存数据
	this.conferenceThreadCache = {};
	*/
	// data: Array --> 缓存的数据
	// folder: number --> 缓存哪个文件夹的数据，
	// page: number --> 缓存哪一页的数据
	setListCache: function(data, folder, page) {
		try {
			if (!this.conferenceListCache['list_' + folder]) this.conferenceListCache['list_' + folder] = {};
			var d = this.conferenceListCache['list_' + folder]['list_' + page];
			if (d && typeof d == 'object') return;
			this.conferenceListCache['list_' + folder]['list_' + page] = data;
		} catch(e) { }
	},
	getListCache: function(folder, page) {
		try {
			if(!this.conferenceListCache['list_' + folder]) return [];
			var d = this.conferenceListCache['list_' + folder]['list_' + page];
			if (d && typeof d == 'object') return d;
			return [];
		} catch(e) {}
	},
	hasListCache: function(folder, page) {
		try {
			if(this.getListCache(folder, page).length == 0) return false;
			return true;
		} catch(e) {
			return false;
		}
	},
	// 如果folder, page参数都传递的情况，那么只清除对应文件夹下对应页面的缓存；
	// 如果只传递folder参数，那么删除当前文件夹下的所有列表缓存
	// 如果不传参数，清掉所有的列表缓存
	clearListCache: function(folder, page) {
		var len = arguments.length;
		try {
			if (len > 1) {
				if (this.conferenceListCache['list_' + folder]) this.conferenceListCache['list_' + folder]['list_' + page] = null;
			} else if (len == 1) {
				this.conferenceListCache['list_' + folder] = {};
			} else {
				this.conferenceListCache = {};
			}
		} catch(e) {}
	},
    // alva
    reply_notifier: function(arg, view, mid){
        var _vis = view == 1 ? true : false;
        if (_vis) {
            try {
                var param = {
                    'disp_flag': 1,
                    'disp_id': mid
                };
                mail_send(param, this.clear_notifier_succ.bind(this), this.clear_with_error.bind(this));
            } catch (e) { }
        } else {
            this.clear_notifier();
        }
    },
    clear_with_error : function(){
        //$('disposition').style.display = 'none';
    	$('disposition_desc').innerHTML = '出错了,请稍后尝试';
        setTimeout(this.clear_notifier, 1200);
    },
    clear_notifier_succ : function(ret) {
    	if(ret.is_success) {
        	this.clearThreadCache(this.currentCid, this.folder);
            $('disposition_desc').innerHTML = "回复成功";
        } else {
            $('disposition_desc').innerHTML = "出错了,请稍后尝试";
        }
        setTimeout(this.clear_notifier, 1200);
    },
    clear_notifier: function(){
    	$('disposition').style.display = 'none';
    },
    // alva
	// 设置星标的缓存(在列表页面进行星标操作时的缓存设置)
	setListStarCache: function(thread, level, folder) {
		try {
			var d = this.conferenceThreadCache['thread_' + folder + '_' + thread];
			if(d && d.length != 0) {
				var l_index = 0;
				this.conferenceThreadCache['thread_' + folder + '_' + thread].each(function(item, index) {
					if(item['deleted'] || item['folder'] == 2) return false;
					l_index = index;
				});
				this.conferenceThreadCache['thread_' + folder + '_' + thread][l_index].star = level;
			}
			this.setListItemPropertyCache(thread, {star: level});
		} catch(e) {}
	},
	// 在读会话页面进行星标操作时的缓存设置
	setThreadStarCache: function(thread, rowid, level, folder) {
		try {
			var d = this.conferenceThreadCache['thread_' + folder + '_' + thread];
			if (!d || d.length == 0) return;
			var max_star_level = 0;
			this.conferenceThreadCache['thread_' + folder + '_' + thread].each(function(item) {
				if(item.rowid == rowid) item.star = level;
				max_star_level = item.star > max_star_level ? item.star : max_star_level;
			});
			this.setListItemPropertyCache(thread, {star: max_star_level});
		} catch(e) {}
	},
	setThreadCache: function(data, thread, folder) {
		try {
			var d = this.conferenceThreadCache['thread_' + folder + '_' + thread];
			if (d && typeof d == 'object') return;
			this.conferenceThreadCache['thread_' + folder + '_' + thread] = data;
		} catch(e) {}
	},
	// 由于会话被读过之后，只会显示最后一封信件的内容，即其他信件display属性将不存在了
	// 这个函数将会在设置会话已读状态之后被触发
	resetThreadCache: function(thread, folder) {
		// 重新组织当前被读过的会话缓存
		try {
			if (!this.conferenceThreadCache['thread_' + folder + '_' + thread]) return;
			var last_display = '', index = 0, last_index = 0, self = this, 
				ctc = this.conferenceThreadCache['thread_' + folder + '_' + thread];
			ctc.each(function(item, index){
				if (!item) return false;
				item.have_read = 1;
				if (item['deleted'] || item['folder'] == 2) return false;
				item.hidedisplay = 1;
				if (ctc[index + 1] && ctc[index + 1].folder == 2) item.hidedisplay = 0;
				last_index = index;
				last_display = item.display;
				// item.display = '';
				// delete item.display;
			});
			this.conferenceThreadCache['thread_' + folder + '_' + thread][last_index].hidedisplay = 0;
			if (last_display != '') {
				this.conferenceThreadCache['thread_' + folder + '_' + thread][last_index].display = last_display;
			}
		} catch(e) {}
		// 设置列表中的已读状态
		try {
			this.setListItemPropertyCache(thread, {unread: 0});
		} catch(e) {}
	},
	getThreadCache: function(thread, folder) {
		try {
			var d = this.conferenceThreadCache['thread_' + folder + '_' + thread];
			if (d && typeof d == 'object') return d;
			return [];
		} catch(e) {}
	},
	hasThreadCache: function(thread, folder) {
		try {
			if(this.getThreadCache(thread, folder).length == 0) return false;
			return true;
		} catch(e) {
			return false;
		}
	},
	// 如果传入thread参数，那么删除对应会话的缓存；
	// 如果不传参数，清掉所有会话的缓存
	clearThreadCache: function(thread, folder) {
		var len = arguments.length;
		try {
			if(len > 0) {
				// 如果只传递thread，那么删除所有文件夹中会话ID为thread的会话；
				if (len == 1) {
					this.F.folders.each(function(item){
						this.conferenceThreadCache['thread_' + item.folder_id + '_' + thread] = null;
					}.bind(this));
				} else {
					this.conferenceThreadCache['thread_' + folder + '_' + thread] = null;
				}
			} else {
				this.conferenceThreadCache = {};
			}
		} catch(e) {}
	},
	// 遍历列表页的缓存列表，找到某一条数据，改变它的某一个属性
	// property: string --> 属性名称；
	// value: string || number --> 属性值
	// 可以是个字典
	setListItemPropertyCache: function(thread, p) {
		for (var key in this.conferenceListCache) {
			var cl = this.conferenceListCache[key];
			if (cl) {
				for (var _key in cl) {
					var _cl = cl[_key];
					if (_cl && _cl.length > 0) {
						_cl.each(function(item){
							if (item.thread == thread) {
								for(var __key in p) {
									item[__key] = p[__key];
								}
							}
						});
					}
				}
			}
		}
	}
};
var mailConference = new MailConference();
